-
Notifications
You must be signed in to change notification settings - Fork 3.1k
An off-the-wall idea: Drop the end filler word and reduce TValues from 16 to 12 bytes. #2333
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
Comments
Well that seems to work fine and TValues are now 12 bytes instead of 16. Why didn't we do this years ago? |
This all seems solid and there's bugger-all difference in the executable size. What I suggest is that we add |
I was just doing some sizing benchmarks and discovered an anomaly which isn't present on standard Lua on the PC -- another eLua bug ;-( An array has two types of entry: a hashed vector used for string keys, etc, and a dense vector of TValues that is used for things like The for loop version works fine on the PC but used the hash entries on the eLua / NodeMCU version. No wonder arrays give memory problems! But at least the new version uses 25⅜ less of too much 😞 I need to dump this eLua 5.1 engine ASAP. |
I was about to raise a separate issue on this But unfortunately my latest LFS patch gives a different result to the current master and to the current PC 5.1.5 version. For a dense 1..N vector a = {unpack(a)} should not free up memory after GC, but it does. Essentially the More investigation needed. |
This sounds similar to the issue in #1434. Did that bug sneak back in? |
Sorry, don't know, but I do know that I need to hose this area of the core to work out why standard Lua out performs our builds, and why my patch is different again. AFAIK, the only changes that I made here where in GC guards, but I need to analyse the diffs on the variants, and work through them with the remote debugger |
OK this one was 1 bug down to me and one down to elua. So with:
The ability be to able to debug a whole class of bugs on the PC using |
I am closing this because the LFS PR implements this. |
Uh oh!
There was an error while loading. Please reload this page.
This doesn't fit into the usual bugfix / feature request but is an off-the-wall idea arising from #2332.
Perhaps the main advantage of the integer builds over the FP ones is that integer Tvalues are 2 words long:
whereas floating point ones are 4 words long:
and in fact the Most Significant Word (MSW) of the value is only used for Number values. The filler word is added because the compiler assumes that doubles must be doubleword aligned and so the TV has to be a multiple of double long. This is the case on the x86 architecture, but on the ESPs all FP is done by S/W routines so only word-alignment is needed. So why not just force
Tvalue
to be word aligned:and hey-presto! Tvalues are now 12 bytes instead of 16. At
-O2
the few instances of*sizeof(TValue)
have o be a*12
instead of<<4
, but otherwise the generated code is the same.. I'd also need to change my pack logic inlflashimg.c
slightly.In the medium term, Lua 5.3 TValues are going to be 8 bytes anyway, but I can see a lot of developers being reluctant to switch to the 5.3 platform until there is a body of confidence in the engine, and with LFS moving most code use and constant string use of out of RAM then dropping the size of TV values by 25% is going to have a material impact of memory free.
So I will try this out and get back to you girls. There might some gotcha that I haven't though of.
The text was updated successfully, but these errors were encountered: