-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Generating a lot of garbage by using BufferAttribute.updateRange #18387
Comments
Do you see the same results with Chrome, TypedArray.subarray() is documented as using the same backing storage as the source object, and should just create a small object wrapping it and not consume much additional memory. |
Chrome memory profiling tools don't do nearly as good of a job, but I do see GC pauses, and relatively large ones, which leads me to believe that memory fragments are fairly large too. That's pure speculation on my part though. |
Maybe better to move the discussion to https://bugs.chromium.org/p/chromium/issues/list and verify the performance of |
Looking at the stats more closely it does look like an overhead of about 90 bytes per array buffer update, so this is probably just the overhead of creating a new ArrayBuffer via subarray() rather than a performance issue with subarray (the issue occurs in FF and Chrome anyway). Which was presumably one of the drivers for the change in the WebGL2 API. There doesn't appear to be any other way of avoiding the problem. Would it be acceptable to query the gl context gl.VERSION at WebGLAttributes construction time and set a flag to select the WebGL API form of the call when using bufferSubData? |
You may want to use the existing |
updateRange
parameter of aBufferAttribute
is intended to improve performance. I use it in my particle engine. I have been doing some performance testing and found following picture to be pretty standard across my game:As you can see, about 26% of the garbage alone comes from here:
three.js/src/renderers/webgl/WebGLAttributes.js
Lines 66 to 88 in 3a3d2b1
Why does this happen? Because WebGL1.0 does not allow you to specify offset and length of the source array that you you supply.
Here's a relevant piece from MDN:
Well, I'm in luck, I do use WebGL2. I'm not sure how to make three.js understand that though, so that we can avoid that needless
.subarray
call that generates all the garbage currently.Any thoughts?
The text was updated successfully, but these errors were encountered: