Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize findLoadedParent #9050

Merged
merged 1 commit into from
Dec 3, 2019
Merged

optimize findLoadedParent #9050

merged 1 commit into from
Dec 3, 2019

Conversation

astojilj
Copy link
Contributor

@astojilj astojilj commented Dec 1, 2019

Performance optimization when rendering view with a large number of raster tiles.
Measurements on Chrome (Version 78.0.3904.108 with CPU 4x slowdown in performance tab) on MacMini i7 3.2 Ghz, 3840 x 1440 display.

map.repaint = true in debug/satellite.html with pitch of 60 degrees

FPS count, like on the screenshot below:
master: 19-20FPS
with this patch: 24.5-26 FPS

Screen Shot 2019-12-01 at 22 40 10

@astojilj astojilj self-assigned this Dec 1, 2019
@astojilj astojilj added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Dec 1, 2019
Copy link
Contributor

@kkaefer kkaefer left a comment

Choose a reason for hiding this comment

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

Could you please describe the algorithm a little bit more, ideally in code comments?

@@ -95,6 +95,16 @@ export class OverscaledTileID {
}
}

calculateScaledKey(targetZ: number, wrap: 0 | 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember that wrap can also be -1 in some situations, or 2 if we show tiles in an extreme wide map view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment.
How does it sound 4673132#diff-e444e40548c379347d0aa642beffc811R99?
Renamed wrap to withWrap as it has boolean semantics here.

Copy link
Contributor

Choose a reason for hiding this comment

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

it should be fine to use use wrap: boolean and true/false for this

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 should be fine to use use wrap: boolean and true/false for this

Prefer to keep 1/0 as they are used in multiplication later. Through ternary or +withWrap would do the same. Documentation should cover it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ansis Thanks.
After offline discussion, withWrap: booleanused and +withWrap in multiplication. Comment updated.
Updated patch pushed.

@astojilj astojilj force-pushed the astojilj-findLoadedParent branch 2 times, most recently from 7d0431c to 4673132 Compare December 2, 2019 14:34
@ansis
Copy link
Contributor

ansis commented Dec 2, 2019

Overall this looks good to me! So the savings are mostly from not needing to create all the tileid objects?

@astojilj
Copy link
Contributor Author

astojilj commented Dec 2, 2019

Overall this looks good to me! So the savings are mostly from not needing to create all the tileid objects?

Yep.
We can further optimize this as it might now make sense to look for a parent this deep - currently, when e.g. rendering raster tile 22 we check for fade parents all the way from 21 to 0.

Performance optimization when rendering view with a lot of satellite tiles.
Measurements on Chrome (Version 78.0.3904.108 with CPU 4x slowdown in performance tab) on MacMini i7 3.2 Ghz.

`map.repaint = true` in http://localhost:9966/debug/satellite.html#12.5/38.888/-77.01866/0/60

Observed FPS count:
master: 19-20FPS
with this patch: 24.5-26 FPS
@astojilj astojilj merged commit ba2d04d into master Dec 3, 2019
@astojilj astojilj deleted the astojilj-findLoadedParent branch December 3, 2019 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants