lua-users home
lua-l archive

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


Hello!

On Wed, Nov 20, 2013 at 9:37 AM, Rena wrote:
> I wonder if there's a good reason for Lua 5.3 or a third-party library to
> add table.new(narr, nrec) (as seen in LuaJIT) to Lua? It seems like a useful
> optimization, and its implementation should only take a couple of lines
> (call lua_createtable() and return).
>

Just as a side note: I proposed the table.new() API to Mike Pall just because

1. the classic Lua C API lua_createtable cannot be JIT compiled,
2. it's more handy to have this Lua primitive ready to use everywhere, and
3. Lua table rehash can easily become a bottleneck for apps heavy on
tables, as seen on on-CPU Flame Graphs (see
https://github.com/agentzh/nginx-systemtap-toolkit#sample-bt )

My lua-resty-mysql library (a nonblocking MySQL client for ngx_lua)
already makes use of this table.new() API:

    https://github.com/agentzh/lua-resty-mysql/blob/master/lib/resty/mysql.lua

Speaking of new Lua primitives, I've also been discussing the new
string.buffer API and table.clear() API with Mike Pall (off-line) for
LuaJIT 2.1, also under the name of performance :)

Best regards,
-agentzh