lua-users home
lua-l archive

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


Hi,

Ivan-Assen Ivanov wrote:
> The function luaS_newlstr showed up on the profiler
> in a significant way, so I decided to investigate what strings are being
> created in our game. To my great surprise, it turned out that
> nearly 70% of the calls to this function are for the string "line" and
> come from the debug hook function (hookf in ldblib.c) which calls our
> own hook function and uses the string "line" to indicate which of the
> event types has occured.

Well, if you are looking for performance then maybe you shouldn't
enable any hook at all. There's a lot more overhead than just the
string allocation. And BTW: the line hook is more expensive than
the count hook.

> Is it possible for these strings used for debug events to be pre-allocated
> in some way, similar to how the metatable predefined keys are
> preallocated in luaT_init?

ldblib.c just defines some simple Lua wrappers around the debug
API functions for the Lua core. You may want to create your own
debug hooks in C. These can be more specialized and e.g. avoid
all of the overhead of calling back into Lua.

Bye,
     Mike