-
Notifications
You must be signed in to change notification settings - Fork 6
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
Cache metamethods, finalize references #1
Conversation
This allows us to speed up LuaRuntime.PushCustomClrObject when pushing an object multiple times since we can do this costly reflection on construction on the object and retain it thereafter. Calling code that uses LuaTransparentClrObject benefits since we can cache this information for the proxy type. It can also benefit calling code that is able to reuse a LuaCustomClrObject instance across multiple Lua calls.
This missing call meant even if the caller took care to dispose a LuaReference it was still being finalized. Adding this call prevents this needless finalization from taking place.
FWIW changes seem reasonable to me. |
What's the plan for getting these changes upstream? |
I'm happy to submit this PR upstream too. Figured I'd do one review committee at a time though :) Having thought about it a bit, I'm wondering if an alternate caching strategy may be better. For example we could cache all this reflection inside the |
Fixes OpenRA/OpenRA#9142, by speeding up the Lua calls for |
👍
|
Can't spot regressions in-game. ✅ |
Cache metamethods, finalize references
This improves performance in two ways:
LuaCustomClrObject
. If a caller reuses the same object in multiple calls, they now only invoke the reflection overhead on the first call. A call involving anyLuaTransparentClrObject
benefits even more as we can cache this once for the whole app-domain.GC.SuppressFinalize
call toLuaReference
. Callers that take care to dispose these properly can now avoid finalizing these objects.Fixes OpenRA/OpenRA#9142