Skip to content

TSL: Improves compilation performance by 3.0x #33120

Merged
sunag merged 12 commits into
mrdoob:devfrom
sunag:dev-optimize-1
Mar 5, 2026
Merged

TSL: Improves compilation performance by 3.0x #33120
sunag merged 12 commits into
mrdoob:devfrom
sunag:dev-optimize-1

Conversation

@sunag

@sunag sunag commented Mar 4, 2026

Copy link
Copy Markdown
Collaborator

Related issue: #31691

Description

Use webgpu_loader_materialx where it previously took on average ~1,550ms to compile all the materials in the scene on my i9 PC; currently, that same time is around ~515ms.

The main reason for the performance improvement was the caching of getNodeType(), where I achieved about a ~2.7x improvement. The rest were some other minor refinements. This should be more noticeable in code that involves many operations.

After some later revisions I introduced generateNodeType() into the class; it seems that the name describes well what happens, whereas the previous getNodeType is oriented toward requests where there is a cache layer.

The tests were performed by summing all builds directly in NodeBuilder.build().

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 359.27
85.31
359.27
85.31
+0 B
+0 B
WebGPU 629.93
174.99
630.28
175
+347 B
+7 B
WebGPU Nodes 628.51
174.74
628.86
174.75
+347 B
+8 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 491.03
119.72
491.03
119.72
+0 B
+0 B
WebGPU 703.55
189.99
703.88
190.04
+331 B
+51 B
WebGPU Nodes 652.76
177.37
653.11
177.48
+352 B
+110 B

@sunag sunag marked this pull request as ready for review March 5, 2026 02:39
@sunag sunag merged commit 0faeeaf into mrdoob:dev Mar 5, 2026
10 checks passed
@sunag sunag deleted the dev-optimize-1 branch March 5, 2026 02:49
@wyliefoxxx

Copy link
Copy Markdown

You deserve another round of applause 👏

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