The International Simutrans Forum

 

Author Topic: Patch: more cache-friendly data layout in convoi_t  (Read 701 times)

0 Members and 1 Guest are viewing this topic.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4877
  • Languages: EN, DE, AT
Patch: more cache-friendly data layout in convoi_t
« on: April 13, 2020, 11:12:34 AM »
Here is a patch that changes the data layout of convoi_t to be more cache-friendly for calls to sync_step and step: the most important data is moved to the front of the structure. Then most of them sits in one cache-line.
gperftools says that this improves the perfomance of these two methods.

Submit?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10663
  • Languages: De,EN,JP
Re: Patch: more cache-friendly data layout in convoi_t
« Reply #1 on: April 14, 2020, 01:11:54 PM »
Yes, please. It will depend on the compiler, but even if it only improved GCC it is worth submitting.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5691
  • Languages: EN, NO
Re: Patch: more cache-friendly data layout in convoi_t
« Reply #2 on: April 15, 2020, 05:18:19 AM »
The compilers have to conform to the same ABI in order to use the same system libraries. So GCC does things differently when compiling for Windows and Linux. One difference has to do with bit-fields. So it might be more platform dependent in practice. (Even more so for different hardware, but that is a bigger challenge to overcome.)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10663
  • Languages: De,EN,JP
Re: Patch: more cache-friendly data layout in convoi_t
« Reply #3 on: April 21, 2020, 01:59:37 PM »
Again, please submit.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4877
  • Languages: EN, DE, AT
Re: Patch: more cache-friendly data layout in convoi_t
« Reply #4 on: April 21, 2020, 05:42:38 PM »
It is, see r9028

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10663
  • Languages: De,EN,JP
Re: Patch: more cache-friendly data layout in convoi_t
« Reply #5 on: April 22, 2020, 01:11:55 PM »
Ups, thanks.