-
Notifications
You must be signed in to change notification settings - Fork 251
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
Instancing performance #1017
Comments
Hi @dvicini I had never given this any thought, or I just forgot about it. This is indeed a pretty big issue for the JIT. As you said, I don't think there is an "easy" fix we can apply. (I'm mostly writing the following two paragraphs for myself) There already is quite a bit of instancing-specific JIT code in Mitsuba. Most of it is to avoid tracing nested vcalls, and recursion issues. But fundamentally we still need to trace every The only solution that comes to mind (that requires no changes to Dr.Jit) is to add a new @Speierers Was this ever considered? Did we break/lose some mechanism that handled all of this JIT-tracing? I guess for meshes the I don't plan on working on this immediately. Or at least not until we've gotten the Anyway, thanks for opening the issue. This will serve as a good reference for anyone else that runs into this issue. |
It's an O(N^2) issue where tracing the recursive ray tracing call in instance wants to visit all shapes again. We have logic in place to that causes these functions to exit early, which makes them cheaper but does not fundamentally fix the asymptotics. The solution I had in mind will be to detect when we are tracing a method call that is identical to one we have already traced (or are currently tracing). .. where identical means: same targets, same input types. In that case, we should be able to reuse the call targets without re-tracing them. This specifically only affects the drjit-core layer, the other parts are unaffected. |
Thanks, yes that all makes sense. I vaguely remembered this being a challenging case, but didn't fully realize the practical implications. Let's keep this issue open for future reference, it's not really urgent to fix it. |
Hi,
I've encountered a performance issue when trying to use instancing. It seems that when instancing simple geometrical primitives, the render time very quickly gets dominated by JIT tracing time. Using the
merge
shape turns out to be a lot faster than instancing (>100x for a very simple rendering). Are we expecting instancing only to be useful when the instanced object reaches a certain complexity (e.g., a 3D model of a tree with millions of triangles)? I am expecting some overhead due to the additional indirections incurred by instancing, but that overhead is currently completely dominated by the JIT tracing time. If I switch toscalar_rgb
mode, instancing and merging shapes perform similarly in my example setup.I don't know how actionable this currently is, but I thought I would open an issue, as this was quite surprising to me.
Here is a minimal reproducer comparing instancing and merging shapes:
The text was updated successfully, but these errors were encountered: