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

Nodes: Optimize getCacheKey(). #30259

Merged
merged 1 commit into from
Jan 3, 2025
Merged

Nodes: Optimize getCacheKey(). #30259

merged 1 commit into from
Jan 3, 2025

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 3, 2025

Related issue: -

Description

Nodes.getCacheKey() is executed at least once per render call so it make sense to optimize this code path as good as possible. This PR does two things:

  • It introduces a module scope array _cacheKeyValues for managing the values that are used to compute the cache key. Previously, an array was created every time a new cache key was required.
  • It only creates the object that holds the cache key data when necessary. Most of the time, existing objects can be updated.

Copy link

github-actions bot commented Jan 3, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.49
79.09
339.49
79.09
+0 B
+0 B
WebGPU 489.83
135.88
489.83
135.89
+6 B
+11 B
WebGPU Nodes 489.29
135.77
489.3
135.78
+6 B
+10 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.35
112.14
465.35
112.14
+0 B
+0 B
WebGPU 559.31
151.37
559.31
151.38
+6 B
+6 B
WebGPU Nodes 515.38
141.15
515.39
141.16
+6 B
+15 B

@sunag sunag added this to the r173 milestone Jan 3, 2025
@sunag sunag merged commit f30af84 into mrdoob:dev Jan 3, 2025
12 checks passed
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