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

Cross tile index performance #16127

Merged
merged 11 commits into from
Jan 22, 2020
Merged

Conversation

pozdnyakov
Copy link
Contributor

@pozdnyakov pozdnyakov commented Jan 20, 2020

Before this change cross tile symbol indexing was a performance bottle neck, for the overscaled tiles in particular. This pull request optimizes the cross tile symbol indexing code path:

  • find matches only among the buckets that have the same leader Id.
  • for overscaled tiles, index only the symbols inside the viewport
  • multiple minor optimizations and code simplifications

Fixes https://github.com/mapbox/mapbox-gl-native-team/issues/133

@pozdnyakov pozdnyakov added performance Speed, stability, CPU usage, memory usage, or power usage Core The cross-platform C++ core, aka mbgl labels Jan 20, 2020
@pozdnyakov pozdnyakov self-assigned this Jan 20, 2020
Copy link
Contributor

@astojilj astojilj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick performance check. The patch improves the performance (1024x768 mbgl-glfw release build on 3.2 GHz 6-Core Intel Core i7 macMini):
a) when there's no pitch, dropped frames take up to 50ms. This was several seconds before.
b) with 60 degree pitch, dropped frames usually take up to 9000ms.

@pozdnyakov, agree with conclusion that this, due to the severity of the issue and even though it is addressing the symptoms and not the root cause (overscaling tiles and buckets we loose the granularity and performance of tiled approach) is worth having as an intermediate fix.

src/mbgl/text/cross_tile_symbol_index.cpp Outdated Show resolved Hide resolved
@pozdnyakov pozdnyakov force-pushed the mikhail_cross_tile_index_performance branch 2 times, most recently from 78fcd82 to a7cacfc Compare January 21, 2020 14:52
@pozdnyakov pozdnyakov marked this pull request as ready for review January 21, 2020 14:52
@pozdnyakov pozdnyakov requested a review from 1ec5 as a code owner January 21, 2020 14:52
@pozdnyakov pozdnyakov force-pushed the mikhail_cross_tile_index_performance branch from a7cacfc to 688f545 Compare January 22, 2020 11:38
if (isInVewport(tileMatrix, symbolInstance.anchor.point)) {
symbolInstance.crossTileID = 0u;
} else {
symbolInstance.crossTileID = SymbolInstance::invalidCrossTileID();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this delay symbol placement by 300ms for out-of-viewport symbols when we pan overscaled tile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it won't, as we reassign those ids at every frame

Copy link
Contributor

@astojilj astojilj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pozdnyakov pozdnyakov merged commit 04edb1d into master Jan 22, 2020
@pozdnyakov pozdnyakov deleted the mikhail_cross_tile_index_performance branch January 22, 2020 12:30
const auto& thisZoomIndexes = indexes[tileID.overscaledZ];
namespace {

bool isInVewport(const mat4& posMatrix, const Point<float>& point) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pozdnyakov should this be spelled isInViewport?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah 😬 thanks for the catch, will fix it in a following patch..

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

Successfully merging this pull request may close these issues.

4 participants