lua-users home
lua-l archive

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


Javier Guerra Giraldez <javier@guerrag.com> 于2020年11月25日周三 上午7:28写道:
>
> On Tue, 24 Nov 2020 at 15:52, Xavier Wang <weasley.wx@gmail.com> wrote:
> >
> > Petri Häkkinen <petrih3@gmail.com>于2020年11月25日 周三03:30写道:
> >> Perhaps it’s again time to consider adding table.new? Rehashing is heavy when initializing these kind of large tables...
> >>
> >
> > Our server was a complete static memory C++ ones for hold many players online (15000 players one process), so we really need table reuse, and the best API we most desired is the lua_resettable()...--
>
> LuaJIT includes both table.new() and table.clear(), many people use
> them extensively on OpenResty (which for some time is LuaJIT only, no
> longer compatible with Lua).   But I've been requested several times
> (on two different companies which pride on high performance) to
> optimize as much as possible some small "hot" parts of the code.  Only
> once I saw a tiny improvement on reusing a table.  I usually don't
> bother with either.  It's usually far more readable to use the curly
> bracket constructors.
>
> Every time I see somebody using table.new()/.clear() without
> benchmarking, I'd like to just remove them, but I know it would be a
> loooong discussion.
>

I have made a benchmarking, in our case one single protocol handler
Lua will use 40KB+ memory (because
in this handler about 1088 object (table or userdata) are created),
after pooling the objects the memory down
to 1KB, so it's still useful in our case :-(


-- 
regards,
Xavier Wang.