Page 1 of 1

For Bryan Hoffmann - but all feedback welcome

PostPosted: 19 Oct 2005, 12:08
by Jack Hyams
I became interested in code optimisation when I read a post that Bryan had written commenting on the amount of time that optimisation of code could take and that good compilers were expensive.

My questions are based on my understanding that

a) All compilers make 2 passes, one to convert high level code into assembler and the second to convert assembler into machine code.

b)The conversion to assembler is the inefficient step because the compiler can't see the wood for the trees ? ie because the compiler does not know what the code is trying to do, it cannot produce efficient assembler.


1)Are a) and b) correct?
2)Is optimisation therefore based on optimising the code after the first compiler pass?
3)Can you predict by looking at the code the amount of time optimisation will take ie does well written code produce significantly better assembler than poorly written code?
4)Is it easier to optimise C than Delfi?
5)If some languages require less optimisation than others, what is the order of these languages?
6)I found that Bryan's optimisation of Fruit 2.1 produced an 8.5% speed increase over the unoptimised code. What speed advantage would well written assembler have over well written and compiled C?
7)What speed advantage would a top compiler give over a standard compiler such as Gcc?
8)Please suggest names and prices of top compilers.



Jack

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 19 Oct 2005, 15:19
by Dann Corbit
This is the wrong way to look at optimization altogether.

The compiler does better than you will at making the code turn into fast assembly.

If you want to optimize, you are far better off using a better algorithm or improving the existing one.

There are lots of sites on code optimization. Many of them are obsolete, because the tricks that used to make things go faster are done automatically by the compiler now.

For example, this is totally obsolete:
http://www.abarnett.demon.co.uk/tutorial.html

Here are some worth reading:
http://www.azillionmonkeys.com/qed/optimize.html
http://g.oswego.edu/dl/oosd/ch25.html
http://www.codeproject.com/tips/optimizationenemy.asp
http://www.prism.uvsq.fr/~cedb/local_copies/lee.html

Bentley, Knuth, Sedgewick, Weiss
Know and love them. Someday, they may save your life.

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 19 Oct 2005, 18:58
by Jack Hyams
Thank you for the links.
Jack

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 20 Oct 2005, 02:10
by Bryan Hofmann
First I want to say, I am not a programmer and will never claim to be nor want to be. What I am able to do is study code that is created by others and make the compiler create a executable the way I see is the fastest. Today's compilers are good at making choices for the most part, but they are general in nature and side on the safe side when doing so. All I do is tell the compiler what should be inlined and what should be a fastcall vs a standard calling conventions. I have found that in these areas I am better at making the choices then the compiler. The reason it takes a great deal of time is due to the fact that alot of trial and error is involved. Some would say it is not worht the extra effort to do this. For me, it is just something I like to do to got the most out of the code.

This may not answer your questions but I would like to leave you with this thought. I once spent an entire weekend of compile test recompile test just to get the end result of another 10K NPS. If this is the sort of thing that interest you then I would recommend you take the route I did and play with different compilers and test different aspects.

BTW I have a Universal MSDN subscription which is on the expensive side.


Bryan

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 20 Oct 2005, 10:00
by Joachim Rang
Bryan, can you please check your mail?

Joachim

Compiler Optimisation

PostPosted: 20 Oct 2005, 17:01
by Jack Hyams
Thank you Bryan. The info. from you and Dann gives me a feeling for the procedure. I don't think this one is going to the top of my list of things to do.
Jack

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 20 Oct 2005, 22:43
by Bryan Hofmann
Joachim Rang wrote:Bryan, can you please check your mail?

Joachim


Checked and did not see anything. I sent you a note.


Bryan

Re: For Bryan Hoffmann - but all feedback welcome

PostPosted: 21 Oct 2005, 08:51
by Joachim Rang
Bryan Hofmann wrote:
Joachim Rang wrote:Bryan, can you please check your mail?

Joachim


Checked and did not see anything. I sent you a note.


Bryan


Strange. If you still don't get emails from me please check your privat messages on this board.

Joachim