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

Avoid expensive resizing in image/glyph atlases #7091

Merged
merged 1 commit into from
Aug 8, 2018
Merged

Conversation

mourner
Copy link
Member

@mourner mourner commented Aug 7, 2018

I noticed that resizing images took a noticeable portion of the worker time. Turns out that we adjust the atlas size when adding every symbol, fully copying the contents each time it is resized. Instead, we can batch-pack an atlas and avoid resizing completely.

In an unscientific test browsing of a Streets map, this shaves off around 100ms of atlases creation (down from 18% to 12% of maybePrepare), and the garbage collector also seems to take around 100ms less time (in a profile where all worker work takes around 3s).

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mourner mourner requested a review from jfirebaugh August 7, 2018 13:16
@mourner
Copy link
Member Author

mourner commented Aug 7, 2018

image

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

Nice!

@mourner mourner merged commit 3110544 into master Aug 8, 2018
@mourner mourner deleted the optimize-atlases branch August 8, 2018 18:08
pirxpilot pushed a commit to pirxpilot/mapbox-gl-js that referenced this pull request Sep 6, 2018
pirxpilot pushed a commit to pirxpilot/mapbox-gl-js that referenced this pull request Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants