Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-06

optimised compiler options for "release" version

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I saw the following options recommended by the ExtPascal project for a final "release" build of ones project. Does this really make a difference in speed/performance and or executable size? How safe is it to deploy such an executable to a wide variety of computers out there.

-O2pPENTIUM4 -CXpPENTIUM4 -XXsi -CfSSE

While developing my software I enable the following, and simply though that for the final "release" version I'll remove the 'heaptrc' support (-gl & -gh) and 'strip' the executable at the end.

-CX -Cr -O1 -gl -gh -XX

What is recommended? Stay with the more conservative options of FPC (-O2 -CX -XX) or the more processor specific optimisations. Please note, that I do not know what exactly our clients run, processor wise (AMD or Intel, singlecore or multi-core, etc...) I would hope everybody at least runs a P4 and up on todays computers.

Regards,
- Graeme -

Graeme Geldenhuys
to Bee
Bee wrote
ExtPascal is more for server side application. You should know where it will be deployed and you can set more appropriate options. ;)

Well, we have a couple of CGI applications written using Free Pascal (using powtils). We deploy it on some 300+ servers. We have no clue what hardware they run on. Hence the reason I asked this question in the first place. We are also looking at deploying these applications as a "distance learning" suite to the public and using a small "embedded web server" instead of Apache.

Our desktop (GUI) applications are also deployed on a few thousand pc's, and again we have no clue what hardware they are running.

Is there some reasonable optimisation parameters we can use for final "release" builds of our software, or should I stick to what I am using now. Lazarus compiler setting defaults and simply disable heatrc and source code line numbers in backtraces.

Regards,
- Graeme -

Graeme Geldenhuys
to leledumbo
leledumbo wrote
AFAIK only -CfSSE? and -Op??? that you have to worry. If you're not sure, just use the lowest possible value (-CfX87 and -Op386). For optimizations, even using -O3 is fine.

Thanks. Do you know what exactly changes when you use various optimization options? Is it primarily executable size or more speed related optimizations?

If it is speed related, how can I actually test the speed differences so see by how much it increases? Does FPC have such tests available somewhere in the source code?

Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/
Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote
leledumbo wrote: > AFAIK only -CfSSE? and -Op??? that you have to worry.

-Op??? is no problem. It's -Cp that can generate code which won't run on previous-generation cpus.

Show quoted text 8 lines
> If you're not sure, > just use the lowest possible value (-CfX87 and -Op386). For > optimizations, > even using -O3 is fine. Thanks. Do you know what exactly changes when you use various optimization options? Is it primarily executable size or more speed related optimizations?

Speed (and also a bit of size, sometimes), but the effects will only be very minor in most cases. Only -Cfsse2 sometimes produces a noticable speedup on more recent processors.

If it is speed related, how can I actually test the speed differences so see by how much it increases?

Just time your program using the Unix "time" command (taking into account the fact that there will always be some amount of jitter).

Does FPC have such tests available somewhere in the source code?

You can try Thomas Schatzl's cpu unit to time small code fragments: http://members.yline.com/~tom_at_work/index.html

Jonas

Graeme Geldenhuys
to Jonas Maebe
Jonas Maebe wrote
-Op??? is no problem. It's -Cp that can generate code which won't run on

OK thanks. Seeing that I don't know the CPU's our program is deployed on, I'll rather stay safe.

very minor in most cases. Only -Cfsse2 sometimes produces a noticable speedup on more recent processors.

Thanks. Do you know what the 'PENTIUMM' cpu is? Is that Mobile Pentium or something?

You can try Thomas Schatzl's cpu unit to time small code fragments:

Thanks, I'll take a look.

Regards, - Graeme - _______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/