lua-users home
lua-l archive

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


Mark Hamburg wrote:
> Which incidentally makes me long a bit for a few more special indices as 
> much for code convenience as performance.

I can understand the part about convenience. But you might be
mistaken on the performance effects of adding a couple more
special indices. Even minor changes to index2adr() can affect the
performance of *all* Lua/C API calls.

If your app is calling a lot of short-running C functions then
index2adr() already shows up near the top of the performance
profiles. And quite often it's one of the main causes for branch
mispredictions.

Adding more (unpredictable) branches to this function is not a
good idea. And it's already too big to be profitably inlined.
Ok, so GCC -O3 will happily inline it, but this causes excessive
code duplication (it doubles the I-cache footprint of lapi.c). 

[Yes, I know that -O3 is no longer generally recommended for use
with GCC 4.x. The better choice is -O2, maybe combined with
-fomit-frame-pointer and -march=i686 for x86, since most distros
still default to i586 (no cmov, no fucomip). Or even -march=native
if the binaries are not distributed.]

--Mike