FeralInteractive / gamemode

Optimise Linux system performance on demand
BSD 3-Clause "New" or "Revised" License
4.67k stars 184 forks source link

[Question] CPU pinning and multi-CCD Zen3 CPUs #460

Open leinardi opened 7 months ago

leinardi commented 7 months ago

Hi, I was wondering if you are aware of any advantages of using CPU pinning with a multi-CCD Zen3 CPU (e.g. Ryzen 5900X and 5950X).

As far as I know only Ryzen 7900x3d and 7950x3d will be autodetected so I was wondering if I should manually set some values for the gamemode.ini's pin_cores and park_cores to get better game performances with my 5950X.

One more question about pin_cores: what values can be set besides yes and no? Is it possible to specify the CPU topography, for example setting that the CCD1 uses cores from 0 to 7 and the CCD2 from 7 to 15 or how can this parameter be used to do some manual core pinning when the autodetect doesn't work?

HenrikHolst commented 4 weeks ago

both pin_cores and park_cores can take the same arguments and as is described in the .ini file they can take yes/no or a list of which cores to park or pin where you can use both comma separated cores and/or - to list a range. I'm adding the text from the .ini file here since it should describe how it works:

; Parking or Pinning can be enabled with either "yes", "true" or "1" and disabled with "no", "false" or "0". ; Either can also be set to a specific list of cores to park or pin, comma separated list where "-" denotes ; a range. E.g "park_cores=1,8-15" would park cores 1 and 8 to 15. ; The default is uncommented is to disable parking but enable pinning. If either is enabled the code will ; currently only properly autodetect Ryzen 7900x3d, 7950x3d and Intel CPU:s with E- and P-cores. ;park_cores=no ;pin_cores=yes

edit: aka "yes" is autodetect, "no" is to disable it all and a list of cores is to force those cores to be pinned or parked regardless of which cpu is used.

leinardi commented 4 weeks ago

I was wondering if I should manually set some values for the gamemode.ini's pin_cores and park_cores to get better game performances with my 5950X.

Hi @HenrikHolst, thank you for your answer, do you have any idea of what would be the best setting for a 5950X? From what I understood the yes value only works with 7900x3d, 7950x3d, but not with 5950X.

HenrikHolst commented 4 weeks ago

I was wondering if I should manually set some values for the gamemode.ini's pin_cores and park_cores to get better game performances with my 5950X.

Hi @HenrikHolst, thank you for your answer, do you have any idea of what would be the best setting for a 5950X? From what I understood the yes value only works with 7900x3d, 7950x3d, but not with 5950X.

The autodetect code only looks at differences in frequency or cache size yes so it does nothing on the 5950X. IF games would benefit from only running on one of the ccd:s of the 5950X (which is something that have to be tested, myself I unfortunately does not have access to such a cpu) then the cores to pin/park have to be entered manually.

Most likely is that the cores on the 5950X is organized so that 0-15 is on one CCD and 16-32 is on the other but to be sure one can use the lscpu command, here from my 5800x3d:

henrik@Sineya:~$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ    MINMHZ       MHZ
  0    0      0    0 0:0:0:0           ja 4548,8281 2200,0000 2872,8069
  1    0      0    1 1:1:1:0           ja 4548,8281 2200,0000 2200,0000
  2    0      0    2 2:2:2:0           ja 4548,8281 2200,0000 2874,6731
  3    0      0    3 3:3:3:0           ja 4548,8281 2200,0000 2235,6079
  4    0      0    4 4:4:4:0           ja 4548,8281 2200,0000 2330,0081
  5    0      0    5 5:5:5:0           ja 4548,8281 2200,0000 2872,9800
  6    0      0    6 6:6:6:0           ja 4548,8281 2200,0000 2200,0000
  7    0      0    7 7:7:7:0           ja 4548,8281 2200,0000 2800,0000
  8    0      0    0 0:0:0:0           ja 4548,8281 2200,0000 2200,0000
  9    0      0    1 1:1:1:0           ja 4548,8281 2200,0000 2200,0000
 10    0      0    2 2:2:2:0           ja 4548,8281 2200,0000 2200,0000
 11    0      0    3 3:3:3:0           ja 4548,8281 2200,0000 3588,6819
 12    0      0    4 4:4:4:0           ja 4548,8281 2200,0000 2200,0000
 13    0      0    5 5:5:5:0           ja 4548,8281 2200,0000 2200,0000
 14    0      0    6 6:6:6:0           ja 4548,8281 2200,0000 2234,9209
 15    0      0    7 7:7:7:0           ja 4548,8281 2200,0000 2793,9910

What we can see here is the core id on the far left and if I'm not mistaken the 5950X have one L3 per CCD so the L3 column which is 0 above should be something like 0 for CCD1 and 1 for CCD2 letting you see which cores is on which ccd. Since the 5800x3d is 8 cores but since HT is enabled it shows it as 16 cores (each core can run 2 threads) so on a 5950X there even might be the potential that 0-15,33-49 is CCD1 for you since you have 16 physical cores but 32 virtual.

leinardi commented 4 weeks ago

This is the output of lscpu -e on my 5950X:

$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ    MINMHZ       MHZ
  0    0      0    0 0:0:0:0           si 5083,3979 2200,0000 3709,1750
  1    0      0    1 1:1:1:0           si 5083,3979 2200,0000 3745,8501
  2    0      0    2 2:2:2:0           si 5083,3979 2200,0000 3747,5991
  3    0      0    3 3:3:3:0           si 5083,3979 2200,0000 3400,0000
  4    0      0    4 4:4:4:0           si 5083,3979 2200,0000 4753,5679
  5    0      0    5 5:5:5:0           si 5083,3979 2200,0000 3679,5449
  6    0      0    6 6:6:6:0           si 5083,3979 2200,0000 3668,8159
  7    0      0    7 7:7:7:0           si 5083,3979 2200,0000 2200,0000
  8    0      0    8 8:8:8:1           si 5083,3979 2200,0000 3512,8560
  9    0      0    9 9:9:9:1           si 5083,3979 2200,0000 2200,0000
 10    0      0   10 10:10:10:1        si 5083,3979 2200,0000 2200,0000
 11    0      0   11 11:11:11:1        si 5083,3979 2200,0000 3638,3140
 12    0      0   12 12:12:12:1        si 5083,3979 2200,0000 3594,3740
 13    0      0   13 13:13:13:1        si 5083,3979 2200,0000 3400,0000
 14    0      0   14 14:14:14:1        si 5083,3979 2200,0000 2200,0000
 15    0      0   15 15:15:15:1        si 5083,3979 2200,0000 3606,3630
 16    0      0    0 0:0:0:0           si 5083,3979 2200,0000 3877,5161
 17    0      0    1 1:1:1:0           si 5083,3979 2200,0000 3744,7119
 18    0      0    2 2:2:2:0           si 5083,3979 2200,0000 2200,0000
 19    0      0    3 3:3:3:0           si 5083,3979 2200,0000 3631,1060
 20    0      0    4 4:4:4:0           si 5083,3979 2200,0000 2200,0000
 21    0      0    5 5:5:5:0           si 5083,3979 2200,0000 2200,0000
 22    0      0    6 6:6:6:0           si 5083,3979 2200,0000 3716,5610
 23    0      0    7 7:7:7:0           si 5083,3979 2200,0000 2200,0000
 24    0      0    8 8:8:8:1           si 5083,3979 2200,0000 2200,0000
 25    0      0    9 9:9:9:1           si 5083,3979 2200,0000 2200,0000
 26    0      0   10 10:10:10:1        si 5083,3979 2200,0000 3615,1311
 27    0      0   11 11:11:11:1        si 5083,3979 2200,0000 3360,0500
 28    0      0   12 12:12:12:1        si 5083,3979 2200,0000 3400,0000
 29    0      0   13 13:13:13:1        si 5083,3979 2200,0000 3935,1531
 30    0      0   14 14:14:14:1        si 5083,3979 2200,0000 4617,4902
 31    0      0   15 15:15:15:1        si 5083,3979 2200,0000 3400,0000

so, if I get it right, CPU 0-7, 16-23 are on the same CCD and 8-15, 24-31 are on the other?

what values would you suggest for pin_cores and park_cores to test if there would be benefits?

HenrikHolst commented 4 weeks ago

This is the output of lscpu -e on my 5950X:

$ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE    MAXMHZ    MINMHZ       MHZ
  0    0      0    0 0:0:0:0           si 5083,3979 2200,0000 3709,1750
  1    0      0    1 1:1:1:0           si 5083,3979 2200,0000 3745,8501
  2    0      0    2 2:2:2:0           si 5083,3979 2200,0000 3747,5991
  3    0      0    3 3:3:3:0           si 5083,3979 2200,0000 3400,0000
  4    0      0    4 4:4:4:0           si 5083,3979 2200,0000 4753,5679
  5    0      0    5 5:5:5:0           si 5083,3979 2200,0000 3679,5449
  6    0      0    6 6:6:6:0           si 5083,3979 2200,0000 3668,8159
  7    0      0    7 7:7:7:0           si 5083,3979 2200,0000 2200,0000
  8    0      0    8 8:8:8:1           si 5083,3979 2200,0000 3512,8560
  9    0      0    9 9:9:9:1           si 5083,3979 2200,0000 2200,0000
 10    0      0   10 10:10:10:1        si 5083,3979 2200,0000 2200,0000
 11    0      0   11 11:11:11:1        si 5083,3979 2200,0000 3638,3140
 12    0      0   12 12:12:12:1        si 5083,3979 2200,0000 3594,3740
 13    0      0   13 13:13:13:1        si 5083,3979 2200,0000 3400,0000
 14    0      0   14 14:14:14:1        si 5083,3979 2200,0000 2200,0000
 15    0      0   15 15:15:15:1        si 5083,3979 2200,0000 3606,3630
 16    0      0    0 0:0:0:0           si 5083,3979 2200,0000 3877,5161
 17    0      0    1 1:1:1:0           si 5083,3979 2200,0000 3744,7119
 18    0      0    2 2:2:2:0           si 5083,3979 2200,0000 2200,0000
 19    0      0    3 3:3:3:0           si 5083,3979 2200,0000 3631,1060
 20    0      0    4 4:4:4:0           si 5083,3979 2200,0000 2200,0000
 21    0      0    5 5:5:5:0           si 5083,3979 2200,0000 2200,0000
 22    0      0    6 6:6:6:0           si 5083,3979 2200,0000 3716,5610
 23    0      0    7 7:7:7:0           si 5083,3979 2200,0000 2200,0000
 24    0      0    8 8:8:8:1           si 5083,3979 2200,0000 2200,0000
 25    0      0    9 9:9:9:1           si 5083,3979 2200,0000 2200,0000
 26    0      0   10 10:10:10:1        si 5083,3979 2200,0000 3615,1311
 27    0      0   11 11:11:11:1        si 5083,3979 2200,0000 3360,0500
 28    0      0   12 12:12:12:1        si 5083,3979 2200,0000 3400,0000
 29    0      0   13 13:13:13:1        si 5083,3979 2200,0000 3935,1531
 30    0      0   14 14:14:14:1        si 5083,3979 2200,0000 4617,4902
 31    0      0   15 15:15:15:1        si 5083,3979 2200,0000 3400,0000

so, if I get it right, CPU 0-7, 16-23 are on the same CCD and 8-15, 24-31 are on the other?

what values would you suggest for pin_cores and park_cores?

for that I would use "0-7,16-23" to pin_cores to put the game only on the first CCD, or "8-15,24-31" in park_cores to park the second CCD. Or switch the values around if you like to pin to the second CCD or park the first CCD.

leinardi commented 4 weeks ago

Thanks! Do you have any recommendation for specific games to use to test if pin/parking will bring gaming performance benefits?

HenrikHolst commented 4 weeks ago

Thanks! Do you have any recommendation for specific games to use to test if pin/parking will bring gaming performance benefits?

sorry, no idea at all. I simply knew that it was an issue with the 7900x3d, 7950x3d and the Intel ones with e and p cores on Windows and added the functionality to GameMode, have zero experience myself since I'm on a 5800x3d (and had a 1600x prior to that). So this is something that you have to try out for yourself if it makes any difference or not.