luaO_chunkid - supply string size as parameter instead of calling strlen()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

luaO_chunkid - supply string size as parameter instead of calling strlen()

Ivan-Assen Ivanov
FWIW: While profiling the startup time of a somewhat big project with a debug hook calling auxgetinfo -> funcinfo a lot, we noticed luaO_chunkid calls strlen on its const char *source argument.
All the places where luaO_chunkid is called in the Lua source, however, have this string length readily (and cheaply) available, either from a TString *, or from a string literal.

We patched it locally, saving almost 100 mln strlen calls on startup.

IMHO the change is small and painless enough - an additional parameter to luaO_chunkID, and a couple of tsslen() macros where it's called - to be considered for a future inclusion. Or am I missing something?
Reply | Threaded
Open this post in threaded view
|

Re: luaO_chunkid - supply string size as parameter instead of calling strlen()

Roberto Ierusalimschy
> FWIW: While profiling the startup time of a somewhat big project with a
> debug hook calling auxgetinfo -> funcinfo a lot, we noticed luaO_chunkid
> calls strlen on its const char *source argument.
> All the places where luaO_chunkid is called in the Lua source, however,
> have this string length readily (and cheaply) available, either from a
> TString *, or from a string literal.
>
> We patched it locally, saving almost 100 mln strlen calls on startup.
>
> IMHO the change is small and painless enough - an additional parameter to
> luaO_chunkID, and a couple of tsslen() macros where it's called - to be
> considered for a future inclusion. Or am I missing something?

You are not missing anything. Thanks for the suggestion.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

RE: luaO_chunkid - supply string size as parameter instead of calling strlen()

Patrick Dorion

unsubscribe

 

 

Patrick Dorion

📱 +1 438 345-4575

 


From: [hidden email] <[hidden email]> on behalf of Roberto Ierusalimschy <[hidden email]>
Sent: Tuesday, April 2, 2019 4:32:05 PM
To: Lua mailing list
Subject: Re: luaO_chunkid - supply string size as parameter instead of calling strlen()
 
> FWIW: While profiling the startup time of a somewhat big project with a
> debug hook calling auxgetinfo -> funcinfo a lot, we noticed luaO_chunkid
> calls strlen on its const char *source argument.
> All the places where luaO_chunkid is called in the Lua source, however,
> have this string length readily (and cheaply) available, either from a
> TString *, or from a string literal.
>
> We patched it locally, saving almost 100 mln strlen calls on startup.
>
> IMHO the change is small and painless enough - an additional parameter to
> luaO_chunkID, and a couple of tsslen() macros where it's called - to be
> considered for a future inclusion. Or am I missing something?

You are not missing anything. Thanks for the suggestion.

-- Roberto