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

Lazy serialization of layers #2306

Merged
merged 9 commits into from
Mar 29, 2023
Merged

Conversation

zhangyiatmicrosoft
Copy link
Contributor

@zhangyiatmicrosoft zhangyiatmicrosoft commented Mar 27, 2023

Launch Checklist

this._serializedLayers dictionary is only needed when the style itself is serialized OR queryRenderedFeatures is called.

Currently it is populated upon creation, which is an overhead for initial map load. This PR changes to lazy serialization.
Based on our experiment, for 150 layers this change saves ~20ms at 75 percentile, and ~100ms at 90 percentile.

Additional changes:

  • "_serializeLayers" is renamed to "_serializeByIds" and piggyback on this._serializedLayers dictionary for better performance. Previously it was doing fresh serialization each time.

  • "setState" method is serializing current instance twice. Fixed.

  • replace forEach with simple for/of loop in "setState". Better performance, easier to debug

  • creating layers is the most time-consuming part of _load method (~80% of time), so split out to be its own method for easier profiling in Chrome performance tool.

  • 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.

  • Write tests for all new functionality.

  • Add an entry to CHANGELOG.md under the ## main section.

zhangyiatmicrosoft and others added 2 commits March 26, 2023 22:07
* Warnonce for Terrain Source (maplibre#2298)

* check for terrain source with hillshade and issue warnonce

* changelog update

* add test and adjust indentation

* improve changelog note

* move test to bottom

* test updated to check console calls

* syntax for CI pass

---------

Co-authored-by: Harel M <[email protected]>

* fix lint

* add test

* change log

---------

Co-authored-by: Victor Gerard Temprano <[email protected]>
Co-authored-by: Harel M <[email protected]>
@zhangyiatmicrosoft zhangyiatmicrosoft marked this pull request as ready for review March 27, 2023 16:48
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
src/style/style.ts Outdated Show resolved Hide resolved
@HarelM
Copy link
Collaborator

HarelM commented Mar 28, 2023

Thanks for taking the time to open this PR!
I've added a few comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants