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

Optimze decoded vector tile transfer from web workers #27

Open
Maximkaaa opened this issue Jan 18, 2024 · 0 comments
Open

Optimze decoded vector tile transfer from web workers #27

Maximkaaa opened this issue Jan 18, 2024 · 0 comments
Labels
A-performance OS-web T-enhancement Improve an existing feature

Comments

@Maximkaaa
Copy link
Owner

Current implementation of the vector tile data transfer from web workers to the main thread is somewhat convoluted:

  1. Convert TesselatedRenderBundle into TessellatedRenderBundleBytes, which is quite cheap conversion of all vertex vectors into byte vectors using bytemuck.
  2. Serialize that structure into byte vector using bincode.
  3. Convert that into JsValue with serde_wasm_bindgen.

And then go in reverse order in the main thread to decode it all. Step 2 and probably step 3 requires all data to be copied, which means that we do 4 copies in total - 2 in the worker and 2 in the main thread. Even such, this is much faster then doing serde_wasm_bindgen deserialization directly for bincode deserialization is much faster.

There are a couple things to consider for optimization:

  1. This comment by one of wasm-bindgen authors suggests, that we can transfer vectors with unsafe code by transferring a pointer, len and capacity (and mem::forgetting the original one). This seems logical, but this method documentation suggests that memory can be changed somehow when allocating anything. This needs investigation, what is true and what is not.
  2. We do MVT tile decoding two times: in the worker and in the main thread. Maybe we can do it only one time...
@Maximkaaa Maximkaaa added T-enhancement Improve an existing feature OS-web A-performance labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-performance OS-web T-enhancement Improve an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant