[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Experiment] Module system based on static hashing
- From: 云风 Cloud Wu <cloudwu@...>
- Date: Mon, 13 Apr 2020 11:34:16 +0800
Stefan <ste@evelance.de> 于2020年4月9日周四 上午8:14写道:
> I've conducted an experiment to speed up Lua state creation with static
> hash tables generated by GNU gperf and got some interesting results.
I uses thousans of lua VMs in one process for years (my project
https://github.com/cloudwu/skynet ) .
So I have the same motivation to optimize the initialization of the VM
, such as loading the libraries.
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.