Skip to content

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Aug 20, 2025

Related issue: #30849

Description

The new approach should improve performance overall, both in compilation and updates, as well as make debugging easier.

The most affected part is array access through numeric constants, which was limited between 0–32. Luckily, it’s uncommon to use constants for values larger than that. In all cases, it’s better to use a.element(b), which accepts dynamic values.

@sunag sunag mentioned this pull request Aug 7, 2025
12 tasks
@sunag sunag added this to the r180 milestone Aug 20, 2025
Copy link

github-actions bot commented Aug 20, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.1
338.91
79.1
+0 B
+0 B
WebGPU 576.19
158.93
576.28
158.83
+87 B
-104 B
WebGPU Nodes 574.8
158.69
574.89
158.59
+87 B
-103 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.7
113.91
470.7
113.91
+0 B
+0 B
WebGPU 646.81
174.91
646.9
174.9
+87 B
-9 B
WebGPU Nodes 600.99
164.09
601.07
164.05
+87 B
-43 B

@cmhhelgeson
Copy link
Contributor

cmhhelgeson commented Aug 20, 2025

Why does switching from Proxy to standard objects improve performance? Are proxy gets/sets slower than regular object get/sets?

@sunag
Copy link
Collaborator Author

sunag commented Aug 20, 2025

Why does switching from Proxy to standard objects improve performance? Are proxy gets/sets slower than regular object get/sets?

Proxy introduces an extra verification layer — imagine that for every value we want to obtain or function we want to call, it has to go through an intermediate interpreter.

We are already using a .getSelf() function to avoid Proxy in uniform update events, which should also be removed in this PR.

@mrdoob
Copy link
Owner

mrdoob commented Aug 21, 2025

Getters and setters were too slow in 2013 so I ended up having to do this: 972c852
I was hoping nowadays things would have improved and we could even use Proxy now, but I guess not...

@sunag sunag changed the title TSL: Remove Proxy approach - WIP TSL: Remove Proxy approach Aug 23, 2025
@sunag
Copy link
Collaborator Author

sunag commented Aug 23, 2025

I’m ignoring the property shortcuts width->x, height->y, depth->w because they’re causing conflicts with some nodes and apparently aren’t used in any example.

@sunag sunag marked this pull request as ready for review August 23, 2025 03:22
@sunag sunag changed the title TSL: Remove Proxy approach TSL: Replace Proxy approach with prototypes Aug 23, 2025
@sunag sunag merged commit f78867d into mrdoob:dev Aug 23, 2025
9 checks passed
@sunag sunag deleted the dev-remove-proxy branch August 23, 2025 04:03
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.

3 participants