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
Understanding RegisterGlobal
#366
Comments
Hi @tznind thank you for the feedback is really nice to see people are using the library. I was wondering why do you need to register so many globals? We can definitely fix the RegisterGlobal to your "fast" implementation as long that doesn't regress any test, feel free to send a PR. |
Thanks for taking the time to reply
I only want to create 4/5 globals. But each time I do
I think what I have done is pretty hacky so probably not ideal (it's on a feature branch of my repo). But I've created a PR which exposes the maximum recursion level of the You can still call all the sub properties and methods (and theres a test using System.DataTable to show that) Let me know if you want me to revert the |
Going to close this now since 7ff6e7c (MaximumRecursion setting) should fix this issue (a small number of complex/deep global class instances resulting in thousands of globals entries being registered). Thanks for all the help tidying the PR @viniciusjarina . |
Is
RegisterGlobal
recursion required to call methods from lua scripts or is it a performance thing?I've been using NLua for ~4 months now and it's amazing! But I have noticed a performance hit that seems to come from registering my globals e.g.
lua["myvar"] = x;
. I think it is because I have quite complex objects with many collections, so I end up with up to ~1200 globals getting registered each time I prepare to run a script.Each script I want to run is very small e.g.
return Actor.Stats[Fight] < 100
so they tend to only touch a fraction of the domain object. But I do call them very often.I notice that the
RegisterGlobal
function stops after 2 levels of recursion but you still seem to be able to call methods beyond that.I have coded a rather hacky workaround to register my root properties without all the recursive reflection exploration (that occurs in
RegisterGlobal
):tznind/Wanderer@cea9b82
I'd like to make it cleaner though and understand if I am doing something very stupid with this.
Any guidance would be much appreciated.
The text was updated successfully, but these errors were encountered: