Sign in Join

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

Mailing lists / fpc-pascal / 2022-10

Problem with code aligning (probably)

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Vojtěch Čihák

Hi,
 
I wrote a generic class to test sorting algorithms and also benchmarking them. I have following problem:  
When I change even a single line of code anywhere in that unit, even in an unrelated method, all ~40 algorithms become a little slower or a little faster. I observed it has two levels of speed: 100% and 90%. Just these values, never 95%, it is not random.  
I looked around and found: https://www.freepascal.org/docs-html/prog/progsu9.html  
but still I cannot find which items and what values should I set. (I guess it should be LOOP, PROC or JUMP?)  
My program is Lazarus single window with many buttons which specializes generic class of that unit.

I'm still on Core2Duo with 64-bit Linux.
 
Lazarus 2.3.0 (rev main-2_3-2118-gb5858164db) FPC 3.3.1 x86_64-linux-qt  
Thanks for help.

Reply by email

Vojtěch Čihák
to Vojtěch Čihák
It seems I have some success with following:
 
{$CODEALIGN LOOP=4}
{$CODEALIGN PROC=4}
{$CODEALIGN CONSTMIN=4}
{$CODEALIGN VARMIN=4}
{$CODEALIGN LOCALMIN=4}
{$CODEALIGN JUMP=4}
 
I expected higher numbers on 64-bit platform. Also, I don't know yet which of the numbers affects my problem.
 
______________________________________________________________
Show quoted text 5 lines
Od: "Vojtěch Čihák via fpc-pascal" Komu: "FPC-Pascal users discussions" Datum: 19.10.2022 15:37 Předmět: [fpc-pascal] Problem with code aligning (probably)

Hi,
...
 
Thanks for help.

Reply by email

Vojtěch Čihák
to Vojtěch Čihák

Hi again, I moved directives from
{$CODEALIGN JUMP=2}
to 

-OaJUMP=2
in Project Options but I still did not found solution. I observed that when code is - after some change - slower, I can solve it by changing -OaJUMP=2 to -OaJUMP=1. And after next change - if it causes slower code - I can solve it reversely: -OaJUMP=1 to -OaJUMP=2.  
Of course, I'd like some persistent solution.
 
V.
 

______________________________________________________________

Show quoted text 5 lines
Od: "Vojtěch Čihák via fpc-pascal" Komu: "FPC-Pascal users discussions" Datum: 19.10.2022 17:39 Předmět: Re: [fpc-pascal] Problem with code aligning (probably)

 
______________________________________________________________

Show quoted text 5 lines
Od: "Vojtěch Čihák via fpc-pascal" Komu: "FPC-Pascal users discussions" Datum: 19.10.2022 15:37 Předmět: [fpc-pascal] Problem with code aligning (probably)

Hi,
...
 
Thanks for help.

Reply by email

Jonas Maebe
to Vojtěch Čihák
Vojtěch Čihák wrote 17 lines
Hi again, I moved directives from {$CODEALIGN JUMP=2} to -OaJUMP=2 in Project Options but I still did not found solution. I observed that when code is - after some change - slower, I can solve it by changing -OaJUMP=2 to -OaJUMP=1. And after next change - if it causes slower code - I can solve it reversely: -OaJUMP=1 to -OaJUMP=2. Of course, I'd like some persistent solution.

That's not easy, unfortunately: https://www.youtube.com/watch?v=r-TLSBdHe1A

Jonas

Reply by email

Vojtěch Čihák
to Jonas Maebe

Thanks, although it's not very optimistic.
 
Is there anything else I can try except {$CODEALIGN ...}? For example change heap or stack size but I don't know what values should I try since I never needed it.  
BTW, is there chance that these problems will go away with newer hardware, like some AM5? New CPUs have at least bigger caches  
Thanks.
 
______________________________________________________________

Show quoted text 5 lines
Od: "Jonas Maebe via fpc-pascal" Komu: Datum: 20.10.2022 08:45 Předmět: Re: [fpc-pascal] Problem with code aligning (probably)

On 20/10/2022 00:24, Vojtěch Čihák via fpc-pascal wrote:

That's not easy, unfortunately: https://www.youtube.com/watch?v=r-TLSBdHe1A <https://www.youtube.com/watch?v=r-TLSBdHe1A>

Jonas

Reply by email

Jonas Maebe
to Vojtěch Čihák
Vojtěch Čihák wrote 5 lines
Thanks, although it's not very optimistic. Is there anything else I can try except {$CODEALIGN ...}? For example change heap or stack size but I don't know what values should I try since I never needed it.

Changing the heap or stack size will have no effect. Changing the order of your procedures could help, and adding dummy code in between as well.

BTW, is there chance that these problems will go away with newer hardware, like some AM5? New CPUs have at least bigger caches

The problems will probably at best move to different spots in your code, unless someone figures out how to make fully associative caches that don't require insane power budgets.

Jonas

Reply by email