Repository navigation
Speed up handing filtered circles to the map - #49
Merged
Merged
Conversation
A carrier toggle in the antenna sample (723,800 circles) spent 5.5 s on an iPad Pro (Debug) in the circle tiler before the map got new tiles, nearly all of it reading the properties of circles that had not changed: 3.4-4.3 s comparing each with the stored geometry, 1.2 s deciding again whether it can be tiled, 0.7 s reading and sorting zIndex. - ShapeTileSet keeps, per slot, the state registered there and its revision (which moves on every write). registeredSlots(_:) matches a list to the slots by identity and revision, walking both in order, so a registered and unchanged circle is known without reading it. - ShapeTiler.route tiles known circles without canTile, and passes their slots to setStates. A list of known circles in the registered order is shown by switching slots on and off (reuseCircleSlots); otherwise known circles give their zIndex from the slot and skip the comparison with the file. A list already in zIndex order is not sorted. - A slot left out by a filter keeps its state (sourceActive says which are drawn), so the state can be matched to it again when it comes back. - The tiler hands the map the template before building the id set, which is bookkeeping. ShapeTiler and ShapeTileSet now take class states only, as all three users are.
Syncing a changed list of 723,800 circles took 1.4 s on the main thread (iPad Pro, Debug): two sets of ids, a dictionary, and a new closure for every state. Each state's StateMutationSignal now holds a listener object, Member, which keeps the pass of sync(_:) the state was last listed in. A sync moves the listed states to the new pass; a state of the last list still on the old pass has left and stops listening; a state without our member has joined. Members are kept across syncs, so nothing is allocated for states that stay. The id dictionary for get(_:) and values() is built when asked for. The public API is unchanged: listen(_:) wraps its closure. A write from another thread now reaches the collector on the main thread.
- AddProgressTracker compared lists with two sets of ids: 0.5-1.0 s on the main thread for 723,800 circles. It now walks the new and the last list side by side by identity, scanning ahead once past a run of removed states, and looks ids up only for objects that did not line up (a new object with an id that left is an update, not a new state). - onAddEnd could come right after onAddStart for a list that only removed states: the hand-over held the main thread past the settle delay, and the tiler had not started yet. The controllers now keep the tiler busy from the start of add until the route has handed the map the tiles, and a settle timer that fires late (the main thread was held) waits once more. - CircleController forgets ids the app dropped after the route instead of before it, so the map gets the tiles sooner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speeds up handing a large circle list to the map after a filter change. On the antenna sample (723,800 circles), turning a carrier off or on took 5.7–6.2 s in Release from tap to
onAddEnd. Drawing the tiles was not the slow part: all 16 tiles finished within 0.3 s, and the slowest took about 0.1 s. Almost all the time went to the hand-over before them.What
revision, which changes on every write.OverlayCollector: who joined or left is found by marking each member with a pass number, not by building sets of ids. This was 1.4 s on the main thread. No public API change.onAddStart/onAddEnd:onAddEndcould come right afteronAddStart, followed by a secondonAddStart. This happened because the tracker could settle before the tiler started.add.12 tests added; all 578 pass. One test writes to a circle between two filters, and checks that the new geometry is drawn. Breaking the revision check makes it fail.
Checked
Antenna sample on an iPad Pro 11-inch, Google Maps, toggling Verizon. Tap to
onAddEnd:onAddStartand oneonAddEnd.The sample-side change is MapConductor/ios-sdk#35.