This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: profile-driven optimization and the linker?


Jeffrey A Law wrote:
http://gcc.gnu.org/news/profiledriven.html doesn't mention
having ld reorder sections to improve locality of reference
of frequently called functions.    Has that technique
been tried with gcc and binutils?

Yes. I had some success with it a while back.

Was that on static executables, or dynamically linked ones?


With ELF it's not terribly hard since we can arrange for
each function to be put in its own section.  Thus you get
to do function-level reordering by just twiddling a linker
map.  In fact, that's where -ffunction-sections name from.

We had some hacks to gprof which would take profile data
and build a linker map.  That's the code that really needs
to be improved.  I never understood the gprof code well
enough to do it right.

I may take a whack at this in my copious free time. Are any such hacks online, or shall I just start from scratch?

I guess further discussion should be on the binutils mailing list.
- Dan

p.s.

I first heard of this technique about 1993 or so, when
Lee Hasiuk implemented it on MS-DOS.

http://mail.kde.org/pipermail/kde-optimize/2003-January/000108.html
describes something similar, but which only aimed at
increasing *disk* cache locality when paging in functions from
disk for the first call.

FWIW, Alan Cox mentioned the technique a couple weeks ago,
http://marc.theaimsgroup.com/?l=linux-kernel&m=109935741612533&w=2
but didn't mention any code.

--
Trying to get a job as a c++ developer?  See http://kegel.com/academy/getting-hired.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]