-
Notifications
You must be signed in to change notification settings - Fork 54
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
Huge performance improvement easily possible #86
Comments
What's the origin of the "500 calls per step"? Do those happen during peak loads of a server, or is it a guessed value? |
well i was making my own trees (that probably needed way more calls than that), and saw that core.is_protected took a significant amount of time on jitprofiler (and no, and yes, this would be better to be in builtin |
The
areas:canInterract
function usesminetest.check_player_privs
without caching the result, this function is put intocore.is_protected
This means, that, if there were 500
core.is_protected
calls per step, it would callminetest.check_player_privs
500 times wastefully, this is not idealStoring the result dramatically increases the performance of
core.is_protected
1st test: without the modification
Test code used:
//lua local t0 = os.clock(); for i=1,1000000 do core.is_protected(vector.new(0,0,0), "the entity") end; core.debug(os.clock() - t0)
Time: 36.27 seconds
2nd test:
Modification used:
areas/api.lua line 98, function is incomplete
Test code used:
//lua local t0 = os.clock(); for i=1,1000000 do core.is_protected(vector.new(0,0,0), "the entity") end; core.debug(os.clock() - t0)
(the same)Time: 3.828 seconds
a 10x improvement (hehe proud of myself!)
The text was updated successfully, but these errors were encountered: