Dynamic symbol table

Karl Vogel karl.vogel at seagha.com
Fri Jul 16 12:53:18 CEST 2004


> Yes, I once did some function reordering based on first usage 
> and that showed 
> indeed some improvement, but I didn't manage to find a 
> convenient way to do 
> that on a larger scale.
> 
> Would be nice if someone could look into that. Just having a somewhat 
> convenient to use tool to identify the hot code would already 
> be a step 
> forward.

I had some attempts/ideas to do this:

1) LD_PRELOAD

Well I first wrote a quick hack to find the execution path of an exe.
I did this with LD_PRELOAD and then mprotect()'ing the main 
executable with PROT_NONE. My hack installed a SIGSEGV signal handler,
so I trapped the pagefaults, recorded the program counter and then
mprotect()'ed the area PROT_READ|PROT_WRITE|PROT_EXEC. 

2) Valgrind

I don't think it would be very hard to use valgrind to record the
startup execution flow. 

--
I first thought of using the execution layout to preload the exact
executable pages, instead of the crude load-the-whole-file preload
tricks.

But then I figured I could use the execution flow layout to reorder
functions in the asm output of GCC, so that everything was close
together and then the preload would be useless. This would have
the added benefit of having a smaller RSS footprint.

HP/Compaq Tru64 has a tool named 'cord' which does this. So I
thought GCC might also have something similar.. and this is when I
saw that GCC can sort-of do this with the
-fprofile-arcs/-fbranch-probabilities. Which is a hell-of-a-lot
simpeler than my original ideas :-)


Just thinking out loud,

Karl.


More information about the Kde-optimize mailing list