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
Labels
Core
The cross-platform C++ core, aka mbgl
performance
Speed, stability, CPU usage, memory usage, or power usage
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]
.mapbox-gl-native/src/mbgl/text/cross_tile_symbol_index.cpp
Line 65 in b820ca4
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:
mapbox-gl-native/src/mbgl/text/cross_tile_symbol_index.cpp
Lines 110 to 111 in b820ca4
So the good news is nothing's broken and we just get a free, easy performance win! 😅
/cc @tobrun @ansis @friedbunny
The text was updated successfully, but these errors were encountered: