-
Notifications
You must be signed in to change notification settings - Fork 25
optimize by localising math functions #83
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
base: master
Are you sure you want to change the base?
Conversation
localise math functions
localise math functions
localise math functions
localise math functions
localise math functions
localise math function
Do these changes make a measurable performance difference on your side? How big of a difference is it? |
@SmallJoker - A few ms here and there, although Nether generation does feel a lot smoother. |
I made the original local math function code that tenplus1 is adding to. It was long enough ago that I don't recall how much speed testing I did or which lua implementation it was on. Any testing I'd done would have been in an earlier (not-nether) mod that used the same kind of mapgen. iirc I was only bothering to make local math functions if an operation was called many times in an inner loop. The big reason to avoid potentially-premature optimization is the added code complexity/legibility/maintenance, and I don't think this applies to tenplus1's changes because they are extremely readable, and also consistent with how the code is already written, enough that they probably make the code more consistent and predictable. So I can't say I have a problem with these changes, regardless of whether there's a noticeable performance difference. (as nice as it would be to know whether nether go faster) |
le Push :P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test setup:
- Luanti 5.14.0-dev
- LuaJIT 2.1.0-beta3 (Ubuntu repository,
libluajit-5.1-2
) - World with dummy back-end
- Teleported into a known nether location with master and PR, and explored most of the (gigantic) cavern.
Testing code:
-- (bottom lines of mapgen.lua)
minetest.register_on_generated(function(...)
local start = core.get_us_time()
on_generated(...)
-- print millisecond time
print(("%.2f"):format((core.get_us_time() - start) / 1000))
end)
master | PR 83 | |
---|---|---|
Samples | 95 | 133 |
Average / ms | 65.56 | 68.99 |
Median / ms | 61.4 | 64.87 |
Time diff. / % | 5.65 |
Interestingly, this PR does result in decreased performance. Would you please be so nice to test this on your system?
Very strange indeed, I teleported to the nether, stood in the exact same spot and did "/deleteblocks here 20" to regenerate an area 10 times, without the changes the final block times were (67.33, 66.90, 55.16) and with the changes the final block times were (48.95, 53.17, 61.34). This is on an AMD Ryzen 7 7840HS with 780M graphics. |
optimizations by localising math functions.