lua-users home
lua-l archive

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


> 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.

Yes, of course, we don't enable any hooks for end users, only in
"developer mode". We are fully aware of the overhead of the hooks -
it just seems that this particular part of the overhead, the constant re-hashing
of the string "line" is completely unwarranted. I don't know much
about the internals of the interpreter, but it seems to me that by keeping these
few strings alive and just giving out references to it the debug hook system
will keep working in exactly the same way, without a noticeable increase
in either code complexity or runtime memory footprint, and with a varying
performance gain for everyone using the debug hooks. Am I missing something?