lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Can you do a little experiment?
- In 5.2.3, do the following change in file lobject.h: 
Then, recompile Lua 5.2.3 and redo your measurements.

(looks at 5.3 lobject.h source) So this is to simulate the cost of adding "struct TString *hnext" in TString?

Lua 5.2.3 unmodified (same figures as before)
====================
lua_newstate: 2032 (1908)
luaL_openlibs: 6400 (6016)
Baseline mem usage: 10120
Module membuf: 1744 (1217)
Module membuf.types: 7880 (7168)
Module membuf.print: 4256 (3649)
Module int64: 1176 (688)
Module oo: 2360 (1842)
Module misc: 1928 (1434)
Module runloop: 5736 (5102)
Module interpreter: 13736 (12808)
Module input.input: 11904 (11012)
Module bitmap.bitmap: 4064 (3461)
Module bitmap.transform: 4096 (3524)
Module tetris.tetris: 41144 (39387)

Lua 5.2.3 with "void *dummy" in TString ("5.2-dummy-TString")
=======================================
lua_newstate: 2352 (2228)
luaL_openlibs: 7184 (6800)
Baseline mem usage: 11376
Module membuf: 1880 (1353)
Module membuf.types: 8368 (7656)
Module membuf.print: 4464 (3857)
Module int64: 1248 (760)
Module oo: 2408 (1890)
Module misc: 1976 (1482)
Module runloop: 6008 (5374)
Module interpreter: 14288 (13360)
Module input.input: 12616 (11724)
Module bitmap.bitmap: 4352 (3749)
Module bitmap.transform: 4280 (3708)
Module tetris.tetris: 42968 (41211)

I also redid the figures for 5.3 without utf8 library, but otherwise the same as 5.2 (ie including bit32, and not removing package.path) so that they are more directly comparable to the 5.2 figures.

Lua 5.3.0 no utf8 ("5.3-no-utf8")
=================
lua_newstate: 2616 (2483)
luaL_openlibs: 7352 (6956)
Baseline mem usage: 11968
Module membuf: 1872 (1334)
Module membuf.types: 8128 (7421)
Module membuf.print: 4352 (3738)
Module int64: 1240 (741)
Module oo: 2384 (1863)
Module misc: 1960 (1459)
Module runloop: 5904 (5259)
Module interpreter: 14280 (13405)
Module input.input: 13568 (12693)
Module bitmap.bitmap: 4400 (3789)
Module bitmap.transform: 4272 (3689)
Module tetris.tetris: 42664 (41023)

lua_newstate usage is now larger although not quite as much as in 5.3. It makes luaL_openlibs usage larger than cut-down 5.3 but not quite to the level of 5.3-no-utf8. Likewise baseline module usage increases but not quite to the 5.3-no-utf8 levels. Module memory usages are generally higher on 5.2-dummy-TString than 5.3-no-utf8, and always higher than 5.2.3-unmodified (as you'd expect).

So it looks like this TString member is the major contributor to the increased memory usage per-module in 5.3, but 5.3 still uses more memory in setting up the initial environment above and beyond the contribution from the TString. There are a few new members in the standard tables that might contribute to that, every extra variable takes up memory. I can live with that though, it's not reasonable to expect new features that take up no space :) I can offset that with the savings of removing bit32, package.path, coroutine etc.

It's interesting how much of an effect the TString member had on the usage of lua_newstate in 5.2.3-dummy-TString, I wouldn't have expected that many strings are constructed before luaL_openlibs or similar has been called.

Cheers,

Tom