Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

CrossTileSymbolIndex is copying itself on every frame #11811

Closed
ChrisLoer opened this issue May 1, 2018 · 1 comment
Closed

CrossTileSymbolIndex is copying itself on every frame #11811

ChrisLoer opened this issue May 1, 2018 · 1 comment
Labels
Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage

Comments

@ChrisLoer
Copy link
Contributor

While trying to follow up on an Android perf issue I noticed that the CrossTileSymbolIndex was showing up way too prominently in the profiler (~10% of CPU time on render thread). It turns out we started copying the entire index on every frame in an otherwise minor back-port of changes from GL JS (feab36a#diff-8f7f3c3dea918c3c149a37c11add87e8)

The problem is that the "auto" here makes a copy instead of taking a reference to the result of indexes[tileID.overscaledZ].

auto thisZoomIndexes = indexes[tileID.overscaledZ];

Changing that to an "auto&" cuts the time spent in CrossTileSymbolIndex::addLayer by about 90%.

The copy doesn't break anything because if we actually need to make a change we explicitly add a new index for the layer:

indexes[tileID.overscaledZ].erase(tileID);
indexes[tileID.overscaledZ].emplace(tileID, TileLayerIndex(tileID, bucket.symbolInstances, bucket.bucketInstanceId));

So the good news is nothing's broken and we just get a free, easy performance win! 😅

/cc @tobrun @ansis @friedbunny

ChrisLoer added a commit that referenced this issue May 1, 2018
Fixes issue #11811 (too much CPU time spent in CrossTileSymbolIndex).
ChrisLoer added a commit that referenced this issue May 1, 2018
Fixes issue #11811 (too much CPU time spent in CrossTileSymbolIndex).
@ChrisLoer
Copy link
Contributor Author

Fixed in #11812.

@ChrisLoer ChrisLoer added performance Speed, stability, CPU usage, memory usage, or power usage Core The cross-platform C++ core, aka mbgl labels May 1, 2018
ChrisLoer added a commit that referenced this issue May 1, 2018
Fixes issue #11811 (too much CPU time spent in CrossTileSymbolIndex).
ChrisLoer added a commit that referenced this issue May 2, 2018
Fixes issue #11811 (too much CPU time spent in CrossTileSymbolIndex).
@tobrun tobrun mentioned this issue May 4, 2018
24 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

No branches or pull requests

1 participant