From: "M. Edward (Ed) Borasky" Date: 2008-01-16T23:51:17+09:00 Subject: Re: any tricks to speed up ruby? -fwhole-program? John Carter wrote: > It's an old trick, I believe the kde folks do it (I may be wrong) > > Instead of creating lots and lots of .o's and linking them... > > Pull all the .c files into one stonking great .c file and compile > that with... > > `-fwhole-program' > Assume that the current compilation unit represents whole program > being compiled. All public functions and variables with the > exception of `main' and those merged by attribute > `externally_visible' become static functions and in a affect gets > more aggressively optimized by interprocedural optimizers. While > this option is equivalent to proper use of `static' keyword for > programs consisting of single file, in combination with option > `--combine' this flag can be used to compile most of smaller scale > C programs since the functions and variables become local for the > whole combined compilation unit, not for the single source file > itself. > > > Takes forever and needs a huge amount of RAM, but it gives the > optimizer more freedom. > > I wonder how hard it would be to tweak the ruby Makefile into doing that? > > > John Carter Phone : (64)(3) 358 6639 > Tait Electronics Fax : (64)(3) 359 4632 > PO Box 1645 Christchurch Email : john.carter@tait.co.nz > New Zealand > > > It's an interesting thought. However, I wasn't able to get gcc 4.2.2 to do some simpler things, like profile-based optimization, on the Ruby source, so I wouldn't expect something that complex to work out of the box. There are a lot of great things in gcc, but not many of them are as well tested as, say, the standard modular C library or program, and, of course, the Linux kernel. As far as I know, "-O3 -march=" is about the best you can get out of gcc without a *lot* of work. And there are a lot more things you can do at the Ruby source level that have a bigger payoff than that does.