Skip to content

Optimize floatVectorToFloatArray for performance improvements - #76

Merged
drumath2237 merged 3 commits into
drumath2237:mainfrom
CesiumGS:main
Mar 23, 2026
Merged

Optimize floatVectorToFloatArray for performance improvements#76
drumath2237 merged 3 commits into
drumath2237:mainfrom
CesiumGS:main

Conversation

@weegeekps

Copy link
Copy Markdown
Contributor

This changes the floatVectorToFloatArray function used heavily during loads to use a faster method for copying the memory from the emscripten context to JS context. This was impacting us during loads of large scenes in CesiumJS, and has resulted in about a full second faster load time with the Microsoft campus dataset.

Our PR in our fork of this repo has some additional instructions and info on how we tested this out: CesiumGS#3

Key changes

  • The function now uses slice to copy data from the WASM heap, which is more efficient and avoids mapping over the buffer by default.
  • Moved from using a map to a for-loop. For small datasets, this doesn't matter, but when simultaneously loading multiple datasets, each with >4 million Gaussians, the additional overhead of map quickly becomes costly.
  • The enhancementFunc parameter is now optional and only applied if defined, reducing unnecessary processing for the default case.

@weegeekps

Copy link
Copy Markdown
Contributor Author

Hi, @drumath2237. This performance issue bubbled up for us with CesiumJS. It would be great to know when you're planning on performing the next release for spz-loader. We are going live with our next release of CesiumJS on the 1st of April. This issue isn't a critical issue for us, but we are rolling out some 3DGS improvements in April that would benefit from this fix.

To make it clear, my intent is not to rush you but just to understand so we can plan appropriately.

Thank you!

@drumath2237
drumath2237 self-requested a review March 20, 2026 23:51
@drumath2237 drumath2237 moved this from 🆕 New to 🏗 In progress in spz-loader Dev Project Mar 20, 2026
@drumath2237

Copy link
Copy Markdown
Owner

@weegeekps

Thank you for your contribution!
I will review this tomorrow or later, as soon as I possible.

@drumath2237

Copy link
Copy Markdown
Owner

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the floatVectorToFloatArray function to improve performance when handling large data volumes. The changes involve using HEAPF32.slice for more direct memory copying from the WASM heap and employing a for loop for conditional data processing, which is more efficient than the previous .map implementation. The enhancementFunc is also now optional, avoiding unnecessary work. After a thorough review, I have not identified any issues or further improvement opportunities in the submitted changes.

@drumath2237 drumath2237 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM!

When I tested it locally with racoonfamily.spz, the decoding speed improved by about 100–300 ms. Thank you so much!

@drumath2237
drumath2237 merged commit 3f309a0 into drumath2237:main Mar 23, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in spz-loader Dev Project Mar 23, 2026
@drumath2237

Copy link
Copy Markdown
Owner

@weegeekps

I have just published version 0.3.1 of spz-loader/core.
Please check it out.

https://github.com/drumath2237/spz-loader/releases/tag/v0.3.1

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

Labels

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants