Repository navigation
Re-show filtered tiled circles without rereading their geometry - #56
Merged
Merged
Conversation
Turning one carrier off in the 723,800-circle antenna sample took about 20 s on a Pixel 5a before the map redrew, 9.2 s of it in ShapeTileSet's check that the filtered list fits the slots already drawn. That check read every circle's geometry with itemAt in draw order, while a large set is stored by place, so nearly every read missed the block cache and went to the file; and it read each state's fields again (about 1.5 us a field off the main thread). - Each slot keeps the snapshot record (CircleState.captureValues()) of the state it was drawn from. A state whose record is still that one matches its slot without reading anything; the rest are compared in one pass in storage order (ShapeTileStorage.forEachItem, block by block for the file). - zIndex is read once per state and sorted as primitives, not read at every comparison by sortedBy. - canTile is not asked again about a state registered before and unchanged since. - The collector skips states that already report to it. Same toggle after: the reuse check 0.78 s, route to template 1.7-2.0 s, tap to the last tile 11-14 s.
This was referenced Nov 21, 2026
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 #54 (it touches the same
ShapeTileSetindex and collector listener code). Merge #54 first. This PR then retargets todevelop.Why
In the 723,800-circle antenna sample on a Pixel 5a, turning one carrier off took about 20 s before the map redrew. Timing probes on the device split it like this:
ShapeTileSetreuse check (does the filtered list fit the slots already drawn?)canTileover every statesortedBy(zIndexOf)The reuse check broke down further:
itemAt6.1 s: oneitemAtper circle in draw order. A large set is stored by place, so nearly every read missed the 40 KiB block cache and went to the file.matches2.7 s andzIndexOf1.0 s: state fields cost about 1.5 µs each to read off the main thread.What
CircleState.captureValues(), passed asShapeTileSet(snapshotOf = …)).ShapeTileStorage.forEachItemreads block by block for the file-backed storage, through the existingforEachRecord.sortedByread it at every comparison.sourceZreuses those values.filterTileable.canTileis not asked again about a state registered before and unchanged since.OverlayCollector.listenToWrittenStatesskips states that already report to it (StateMutationSignal.isListenedBy), and touchespendingAddsonly when it is non-empty.No public API change (
apiCheckpasses).Measured (same toggle, Pixel 5a, 3 runs)
canTilepassThe remaining time is mostly the compose hand-over, which varied from 4 to 6 s between runs:
Circlesremoving 147k ids from the persistent map: 1.4 sChecked
:android-sdk-core:testDebugUnitTest: 448 pass.apiCheckpasses.CircleTileFileDeviceTest,CircleTilerDeviceTest): 17 pass, including the newfilteringReusesTheFile_andAChangedCircleIsComparedNotTrusted. It checks that: