Repository navigation
Hand bulk collections over as a list, and track collector listeners by pass - #57
Merged
Merged
Conversation
listenToWrittenStates looked every id of the new map up in the old one and every id of the old map up in the new one: about 1.7 s on the main thread for the 576k/724k circles of the antenna sample on a Pixel 5a. The collector now listens through a PassToken replaced at every pass. A state in the new map is moved to the current token; a state of the old map still on an older token of this collector was not in the new one, and stops. One read per state, no lookups; an id is still looked up for a state not yet listening here, to stop what held that id before. The pass is now 1.2-1.3 s. Of that, merely iterating the PersistentOrderedMapBuilder is about 0.44 s per 576k entries (it looks the next key up at each step), which only a different hand-over can avoid.
A collector's membership is a MutableMap, and for a bulk collection that map was a PersistentOrderedMap of every state: building it took about 1.8 s per hand-over for the antenna sample's 576k circles on a Pixel 5a, and merely iterating it about 0.44 s per pass (it looks the next key up at each step), on the collector's pass and the overlay's toList. OverlayStateList is a MutableMap over the list a collection was given: iterating it walks the list, and only a key lookup builds an index. The collector's listener pass and CircleOverlay walk the list; the overlay hands the list itself to the controller, and the added-tracker gets the ids lazily. A write from the latest pass's token is known to be from a member without a lookup. A published map is still not to be written to; one that is follows its index. The ids must be distinct (the compose Circles hands a list over only when they are).
This was referenced Nov 21, 2026
Merged
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.
Stacked on #56, which is stacked on #54. Merge those first; this one then retargets.
Pairs with MapConductor/android-sdk-compose (Circles list hand-over), which needs the
OverlayStateListadded here.Why
After #56 the antenna sample (723,800 circles, Pixel 5a) still took 11–14 s from a carrier toggle to the last tile. Most of what remained was the compose hand-over through the collector's persistent map:
Circlesmerging its list into a copy of the persistent map (removing 147k, putting 576k)values.toList()inCircleOverlayMerely iterating a
PersistentOrderedMapBuilderof 576k entries takes about 0.44 s, because it looks the next key up at each step.What
Two commits:
PassTokenreplaced at every pass.OverlayStateList. AMutableMapover the list a collection was given.LinkedHashMap, built on first use).CircleOverlay.renderwalk the list, and the overlay hands the list itself to the controller.OverlayAddedTrackergets the ids lazily.No public API change.
OverlayStateListandPassTokenare@InternalMapConductorApi, andapiCheckpasses.flowkeeps its type, so readers that look ids up still work, at the cost of building the index once.Measured (with the compose PR, same toggle, Pixel 5a, 3 runs)
Circleseffect to publishedThe pass-token commit alone took the pass to 1.23–1.29 s. The iteration cost above is the part only the list hand-over removes.
Checked
:android-sdk-core:testDebugUnitTest: 451 pass. New tests:apiCheckpasses.