Sign in Join

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

Mailing lists / fpc-pascal / 2009-01

Maybe one stupid question

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

JoshyFun

Hello FPC-Pascal,

I'm using FPC 2.2.2 running over WinXP SP2. Are there any technical reasons that expains that a program runs faster using all checks ( I/O, Range, Overflow, Stack and Verify calls ) with optimization level 1 and using heaptrace, than the same one compiled without any check, optimization level 2 or 3 and not using heaptrace ?

I had expected around a 5% faster with the non-checks config, but I get a 2% slower program :-?

Everything has been tested using Lazarus 1 month SVN, using a 1 minute runtime check.

Best regards, JoshyFun

Reply by email

JoshyFun
to leledumbo

Hello leledumbo,

Friday, January 23, 2009, 7:55:28 AM, you wrote:

l> Perhaps bugs in the optimizer, I usually get MUCH faster code with l> optimization. Well... depending on the code. You can try examining the l> assembler output (-a compiler switch, -alnrt for more informative output).

I had done it, but the assembler output does not help too much as the .s files are 4 megabytes :) and the performance loose is somehow distributed around all the code.

My last test is even worst, same settings except the heaptrace, better performance with heaptrace activated :-? I think that I must check that Lazarus is passing all parameters well to fpc...

Best regards, JoshyFun

Reply by email

Eduardo Morras
to JoshyFun: I'm using FPC 2.2.2 running over WinXP SP2. Are there any technical reasons that expains…
you wrote 7 lines
Hello FPC-Pascal, I'm using FPC 2.2.2 running over WinXP SP2. Are there any technical reasons that expains that a program runs faster using all checks ( I/O, Range, Overflow, Stack and Verify calls ) with optimization level 1 and using heaptrace, than the same one compiled without any check, optimization level 2 or 3 and not using heaptrace ?

Perhaps your level 1 code fits in level 1-2 cache, and your level 2-3 don't, causing more cache misses. Try to compile with -Os instead level 1-2-3 and see if it's faster.

Show quoted text 13 lines
I had expected around a 5% faster with the non-checks config, but I get a 2% slower program :-? Everything has been tested using Lazarus 1 month SVN, using a 1 minute runtime check. -- Best regards, JoshyFun _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

JoshyFun
to Eduardo Morras

Hello Eduardo,

you wrote 5 lines
>I'm using FPC 2.2.2 running over WinXP SP2. Are there any technical >reasons that expains that a program runs faster using all checks ( I/O, >Range, Overflow, Stack and Verify calls ) with optimization level 1 >and using heaptrace, than the same one compiled without any check, >optimization level 2 or 3 and not using heaptrace ?

EM> Perhaps your level 1 code fits in level 1-2 cache, and your level 2-3 EM> don't, causing more cache misses. Try to compile with -Os instead EM> level 1-2-3 and see if it's faster.

Test done also, the -Os does not provide a significative change. Just to show some numbers:

with -Os, all checks (overflow...) iteration time: 3.650 secs. with -Os, all checks + heaptrace iteration time: 3.517 secs.

So, heap trace makes programs faster :-?

The cache theory is fine, but the -O2,-O3 produces smaller code than -O1 (less calls and memory accesses) but program runs slower.

I had also tried to use cmem instead the default memory manager and as expected the results are worst, iteration time 3.870 seconds.

Also gprof is not helping too much because there are no clear differences about calls in both optimized and non optimized modes, except the calls to range check, object check and others as expected in the "with checks" version which runs faster :-?

With gprof I saw in my code a lot of FillChar calls (which are not in my code at all), so I think that they comes from the internal initializations of variables and records, unfortunatly the calls counter does not appear (spontaneous), and the fact that heaptrace produces faster code makes me think in the memory manager, but without a conclusion to this "trivial".

Best regards, JoshyFun

Reply by email