I replaced JSON parsing for all highlight candidates (at most, 500) with a
faster estimation using regex: we only use the full JSON parsing to get the
perfect values for the items to be shown (~5).
One caveat of this change: JSON parsing will be moved to the main thread when
the getMetadataSlow is lazily-loaded.
Disclaimer: my device seems to be running faster than yesterday so profiling
may not be consistent but here are the profiling results:
- HighlightsRanking.extractFeatures: 78.1% -> 54.5%
- Highlight.<init>: 26.5% -> 14.5%
- JSONObject.<init>: 11.4% -> rm'd
- initFast*: (replaced JSONObject.<init> & friends) -> 4.2%
With ^ the disclaimer in mind, runtime decreased from 12.6s to 5.3s (this is
slower due to profiling).
MozReview-Commit-ID: CTqAyDDmaJQ
After the previous changeset, some numbers stood out:
- HighlightsRanking.extractFeatures: 44.9%
- HighlightCandidate.getFeatureValue: 19.4%
- Collections.secondaryHash: 17.3%
- HashMap.get: 11.7%
My hypothesis was that our HighlightCandidate.features implementation was slow:
it was mapping FeatureNames -> values in a HashMap but HashMap look-ups are
slower than a direct memory access.
I replaced the implementation with a direct access from an array - about as
fast as we can get. This encouraged me to make some changes with the following
benefits:
- Rewrote HighlightsRanking.normalize to save iterations and allocations.
- Rm code from HighlightsRanking.scoreEntries: we no longer need to iterate to
construct the filtered items, we just index directly into the list
- Rewrote HighlightsRanking.decay(), which I think is a little clearer now.
- Saved a few iterator/object allocations inside inner loops in places.
The tests pass and we have coverage for the normalize changes but not for
scoreEntries.
---
For perf, my changes affected multiple methods so the percentages are no longer
reliable but I can verify absolute runtime changes. I ran three tests, the best
of which showed an overall 33% runtime compared to the previous changeset and
the other two profiles showed a 66% overall runtime. In particular, for the
middle run, the changes for affected methods go from X microseconds to Y
microseconds:
- Features.get: 3,554,796 -> 322,145
- secondaryHash: 3,165,785 -> 35,253
- HighlightsRanking.normalize: 6,578,481 -> 1,734,078
- HighlightsRanking.scoreEntries: 3,017,272 -> 448,300
As far as I know, my changes should not have introduced any new inefficiencies
to the code.
MozReview-Commit-ID: 9THXe8KqBbB
This reduces the calls to `getColumnIndexOrThrow` to 9 (from 1.6k) and
HighlightsRanking.extractFeatures goes from 77.1% inclusive CPU time -> 40.8%,
14.6k ms -> 7.1k ms.
MozReview-Commit-ID: L6HqvBK5I4i
This change is fixing an issue unrelated to this bug.
It was using Visits.HISTORY_GUID, which is not in the table and thus doesn't
make sense for the first clause of the foreign key constraint. Visits & its
replacement have the same value so the behavior should not change.
MozReview-Commit-ID: 8EbJh586DN3
I could not make sense of the existing names at all.
Bug 1379021 is going to:
- Remove the vTimeSince view, so I didn't change the name
- Create a new layout file, so I didn't change the resource IDs accordingly
MozReview-Commit-ID: 1WUzyhrzQYZ
I'm a little concerned that this will hide other bugs but it's pretty
complicated to track down without an STR (e.g. what are all the possible ways
we load the HomePager with TopSites as the default and swap in new highlights?
How about unloading? When is onSizeChanged called?) so I don't think it's worth
investigating further.
MozReview-Commit-ID: 6OuFJ2iQsdL
For photon we need to add some colors.
I don't want change current color and dimen too much. I want to add new resources if possible to avoid confliction.
For Tab Items, there are three layout
1. AutoFitTabsGridLayout. Used in tablet-land/port and phone-land
2. CompactTabsGridLayout. Used in phone-port(with pref on)
3. TabsListLayout. Used in phone-port(default)
In 1.2, we only constrain the gap of the Tab item padding and the layout padding.
In 3, we restrain the thumbnail width to 137dp .
I also make the tab strip longer for tablet. And I change the color of tab item border and set the thumbnail ratio to 4:3.
We might need to remove unused resources and test different density(2.6 and 3 are all xxhdpi!) and sw240,sw360,sw400 combination.
MozReview-Commit-ID: Gp25nG8NkR5
The bootstrap catalog is outdated and downloading files from it returns in 404 errors from the CDN.
It's impossible to keep the bootstrap catalog updated. Instead let's start with an empty catalog
and rely on the latest catalog that we synchronize from Kinto.
MozReview-Commit-ID: FduZWJBvj16
I verified this fixed the issue by:
- Attaching a debugger and checking against the STR call order (comment 3).
- Ensuring the favicons in the SearchEngineRow looked correct
MozReview-Commit-ID: GJeh3FLim36