The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: jk271 on February 17, 2012, 04:01:39 PM

Title: compillation speed up in besch/vehikel_besch
Post by: jk271 on February 17, 2012, 04:01:39 PM
This patch does not add or remove any functionality.
It can speed up a little bit building process of game.

There are long functions in besch/vehicle_besch.h file now. (At least one is too long for header file in my opinion.) This header file is included in three files directly and in around twenty files indirectly (via another header file). Moving bodies of functions from .h file to .cc file removes unnecessary text processing.

I have measured time of build (several times)  and with patch it is about 0.5-0.6s faster than old version.
Title: Re: compillation speed up in besch/vehikel_besch
Post by: isidoro on February 17, 2012, 05:52:17 PM
The problem (I don't know about if these methods are critical in this aspect) is that if you take them away from the .h, they cannot be inlined by the compiler if it wishes to.  A very frequent inlined method can save a function call and be quicker in execution time.

Title: Re: compillation speed up in besch/vehikel_besch
Post by: jk271 on February 17, 2012, 09:05:47 PM
I had seen no "inline" modifier there so I had assumed that they had not been inline.

After reading your response I tried to look up more details about inline functions. I found that functions without "inline" modifier might be used as "inline" by compiler. I had not known that.

Thank you for highlighting such a behavior of function inlining.

It changes my assumption of no :"game performance change" to "performance change unknown". I did not realized significant performance decrease. Unfortunately I am not familiar with gprof yet to provide any figures.
Title: Re: compillation speed up in besch/vehikel_besch
Post by: prissi on February 17, 2012, 11:20:27 PM
Only get_bild_nr is called somewhat more frequently. But this was only 0.09 % of total time.
Title: Re: compillation speed up in besch/vehikel_besch
Post by: jk271 on February 20, 2012, 11:54:01 PM
Thank you, prissi, for providing exact figures.