lua-users home
lua-l archive

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



Am 13.04.2020 um 05:34 schrieb 云风 Cloud Wu:
> My solution is patching the lua VM to support :
> 
> 1.  Sharing the function protos.
> http://lua-users.org/lists/lua-l/2014-03/msg00489.html
> 2.  Removing short string interning.
> http://lua-users.org/lists/lua-l/2019-06/msg00413.html
> 3.  Adding a bit to the mark of GCObject to prevent modification of a table.
> 
> And then , we can create a constant lua (library) table out of VM ,
> and use it directly in multiple lua VMs. The same technique can be
> used for a large datasets. We can load a lua table with huge datasets
> in a seperated thread/VM , and access it in other multiple lua VMs
> directly.
> 

This sounds interesting!
I've added your modified Lua 5.3 to the test repository:
https://github.com/evelance/lxlib/tree/09bf1392a74713fb7bd393b99c8aaa7ba3482f4f

Results:

$ /usr/bin/time -v out-cw
Create states     -  0.8799s
Load libraries    -  9.6391s
Load bytecode     -  0.5459s
Execution         - 10.4809s
memory usage per state: 23KB
full gc cycle     -  2.1766s
Cleanup           -  2.9592s
...
User time (seconds): 24.23
Maximum resident set size (kbytes): 2737564

vs regular Lua 5.4:

$ /usr/bin/time -v out-normal
Create states     -  1.0951s
Load libraries    - 10.7178s
Load bytecode     -  0.5136s
Execution         - 10.2568s
memory usage per state: 22KB
full gc cycle     -  2.6487s
Cleanup           -  1.5583s
...
User time (seconds): 24.59
Maximum resident set size (kbytes): 2713996

But how to use it? Just like regular Lua?
Or am I missing something?