-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
WebGPURenderer: Fix V8 deoptimizations. #32405
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
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
@mrdoob its super nice! Im curious how you are testing all these recent improvements? |
In different ways. Which ones are you curious about? |
|
@mrdoob I saw for the visual one its very straightforward image comparaison + reference blender/khronos , but for this one and the one about really small performance gain i cant even notice on my devices usually, so curious if its directly from profiler or other tooling ? |
| const uniformName = builder.getPropertyName( nodeUniform ); | ||
|
|
||
| if ( builder.context.nodeName !== undefined ) delete builder.context.nodeName; | ||
| if ( builder.context.nodeName !== undefined ) builder.context.nodeName = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TSL context system is designed to work in a cascading manner, similar to CSS; in that sense, setting it to undefined is different from removing it.
Deleting
const a = {
property: 'value'
};
const b = {
property: 'override'
};
delete b.property;
const result = { ...a, ...b };
result.property // valueDefining as undefined
const a = {
property: 'value'
};
const b = {
property: 'override'
};
b.property = undefined;
const result = { ...a, ...b };
result.property // undefinedI personally don't like assignments like undefined, because we often use undefined to detect a variable that has never been assigned, but when it is assigned as 'undefined', the key remains assigned to the object while delete removes the entire property.
If the idea is to preserve the structure of the objects, it's preferable to define them as null in the declaration, as we already do in classes.
Description
This PR addresses several V8 deoptimization patterns in the WebGPU renderer to improve performance and stability.
RenderObject.js: OptimizedgetKeysby caching prototype keys in a WeakMap, significantly reducing reflection overhead.Renderer.js,Nodes.js,NodeBuilder.js,UniformNode.js: Replaceddeletekeyword usage withundefinedassignment to prevent hidden class transitions and keep object shapes stable.These changes ensure more stable hidden classes and reduce garbage collection overhead associated with dictionary mode objects.