Performance improvements of some lua APIs#99
Open
Helyos96 wants to merge 1 commit intoPathOfBuildingCommunity:masterfrom
Open
Performance improvements of some lua APIs#99Helyos96 wants to merge 1 commit intoPathOfBuildingCommunity:masterfrom
Helyos96 wants to merge 1 commit intoPathOfBuildingCommunity:masterfrom
Conversation
* Use lua_tonumberx/lua_tointegerx instead of separated calls like lua_isnumber/lua_tonumber * Avoid evaluating luaL_typename in the asserts when there is no need (these were always evaluated even when the assert didn't trigger) * Drop the sscanf() call in ReadColorEscape * Avoid calling IsColorEscape twice for ReadColorEscape
zao
approved these changes
Apr 27, 2026
Contributor
zao
left a comment
There was a problem hiding this comment.
The transformations look valid from reading the code and it builds locally.
I didn't run any performance tests but the reasoning here seems sound.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While profiling SimpleGraphics, I saw that
l_DrawImage,l_DrawImageQuadandl_SetDrawColorwere very consuming while in tree view (not very surprising).I found a few improvements to do, which mostly revolve around eliminating some calls to luaJit and dropping a costly sscanf().
Profiling before:
And after:
The most obvious gain is
l_SetDrawColorwith sscanf being dropped. Thel_DrawImagefunctions saw fewer gains but still less time spent in lua functions, especially the calls to lua_type went much lower.Looking at task manager, PoB went from ~6.5% (maxing out one logical core) to ~5.9%. It could be that in doing so I gained a few fps, which skewed a bit the profiling data since these functions got to be called more.