Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Mike Pall <mikelu-0910 <at> mike.de>
Subject: Re: Special indices (was Re: LightUserData and metatables)
Newsgroups: gmane.comp.lang.lua.general
Date: Monday 12th October 2009 18:37:17 UTC (over 7 years ago)
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
 
CD: 2ms