Request to the Dev team - Optimisation

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
mcgiwer
Inserter
Inserter
Posts: 39
Joined: Sat Aug 14, 2021 8:12 pm
Contact:

Request to the Dev team - Optimisation

Post by mcgiwer »

Hello. I would like to ask the game development team to use while the compilation process following compilator switches:

Code: Select all

-O3 -Os -pipe
This way, the code becomes optimised for the speed and low size, thru with Factorio would work faster then currently. Thanks ;-)

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Request to the Dev team - Optimisation

Post by mrvn »

-O3 is often slower. You should really only use it in cases where you tested that it improves speed.

And I'm sure you forgot to include LTO. While that takes massive time and memory to then link the game the improvement is often huge. If you have enough memory for it. :(

mcgiwer
Inserter
Inserter
Posts: 39
Joined: Sat Aug 14, 2021 8:12 pm
Contact:

Re: Request to the Dev team - Optimisation

Post by mcgiwer »

mrvn wrote:
Fri Sep 10, 2021 3:05 pm
-O3 is often slower. You should really only use it in cases where you tested that it improves speed.
I had tested the "-O3 -Os -pipe" parameters setting and the compiled application was working faster then without them.

In case it got forgotten:
  • -O3 -> optimises the code for speed
  • -Os -> optimises for size
  • -pipe -> optimises compilation speed
And I'm sure you forgot to include LTO. While that takes massive time and memory to then link the game the improvement is often huge. If you have enough memory for it. :(
I haven't tested it yet, but I may try in future coding

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Request to the Dev team - Optimisation

Post by mrvn »

mcgiwer wrote:
Fri Sep 10, 2021 3:38 pm
mrvn wrote:
Fri Sep 10, 2021 3:05 pm
-O3 is often slower. You should really only use it in cases where you tested that it improves speed.
I had tested the "-O3 -Os -pipe" parameters setting and the compiled application was working faster then without them.

In case it got forgotten:
  • -O3 -> optimises the code for speed
  • -Os -> optimises for size
  • -pipe -> optimises compilation speed
And I'm sure you forgot to include LTO. While that takes massive time and memory to then link the game the improvement is often huge. If you have enough memory for it. :(
I haven't tested it yet, but I may try in future coding
-pipe means the compiler outputs the assembly code directly to as through a pipe instead of writing a tempfile and running cc and as sequentially. Gives a little bit of parallelity but if you build with -j already it should be irelevant.

As for LTO that enables whole program optimization instead of only optimizing each compilation unit on its own. Means function from one *.cc file can be inlined in another. Like when you have for example this little wrapper in map.c: (loosely from freeciv)

Tile * get_tile(int x, int y) { return tiles[x][y]; }

Instead of making a function call for every tile access suddenly the array access is inlined. I got freeciv 4 times as fast simply by using LTO some years back. The difference can be huge or it can be 0.

eternal_biter
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Sep 08, 2021 4:16 am
Contact:

Re: Request to the Dev team - Optimisation

Post by eternal_biter »

mcgiwer wrote:
Fri Sep 10, 2021 2:22 pm
Hello. I would like to ask the game development team to use while the compilation process following compilator switches:

Code: Select all

-O3 -Os -pipe
This way, the code becomes optimised for the speed and low size, thru with Factorio would work faster then currently. Thanks ;-)
These optimization flags more often than not cause more problems than they solve. It's nice you're learning about compilers, but this suggestion is wholly unnecessary & somewhat dangerous/waste-of-time.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Request to the Dev team - Optimisation

Post by ssilk »

I’m 100% sure the devs make optimizations that are far, far beyond these simple compiler flags.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

mrvn
Smart Inserter
Smart Inserter
Posts: 5704
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Request to the Dev team - Optimisation

Post by mrvn »

There is also a very good paper (sorry, can't find it right now on google) that compares the effect of "gcc -O2 vs. gcc -O3" and e.g. setting an environment variable so the stack alignment for the program is shifted. The conclusion is that the (stack) alignment has more effect on the speed of code than gained by -O3 over -O2.

Or in other words the gain of -O3 over -O2 is less than the random noise caused by the users environment being different or address space randomization by the kernel.

Post Reply

Return to “Ideas and Suggestions”