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

Improve performance by processing style layers in parallel #2131

Merged
merged 6 commits into from
Feb 9, 2023

Conversation

pramilk
Copy link
Contributor

@pramilk pramilk commented Feb 3, 2023

Change

Style processing (createStyleLayer method) is one of the most expensive operations performed during initial load and also during style change. This takes anywhere from 100-400ms, depending on machine speed, number of layers, expressions used in style etc.

  • Currently: Styles are validated (If validation is enabled) --> Styles are processed on main thread (via createStyleLayer function) --> broadcasted to all worker threads --> Styles are processed on each worker thread (via createStyleLayer function).

  • New change: Styles are validated (If validation is enabled) --> broadcasted to all worker threads --> Styles are processed in parallel (via createStyleLayer function) on both main and worker thread.

Note: In our observation doing a prewarm or an external worker as per this PR (#2130), gives much better results as worker threads are ready by the time it gets the broadcast message to truly allow parallel processing.

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

src/style/style.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Feb 6, 2023

Can you please add a test to test that somehow?

@pramilk
Copy link
Contributor Author

pramilk commented Feb 9, 2023

Can you please add a test to test that somehow?

Added some tests. Also while testing realized that "custom" filter is not required as a style Json does not support it. Added some more tests for it.

@pramilk pramilk changed the title Improve performance by processing style data in parallel Improve performance by processing style layers in parallel Feb 9, 2023
@HarelM HarelM merged commit 7351d2f into maplibre:main Feb 9, 2023
@HarelM
Copy link
Collaborator

HarelM commented Feb 9, 2023

THANKS!

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.

3 participants