sched-ext / scx

sched_ext schedulers and tools
https://bit.ly/scx_slack
GNU General Public License v2.0
689 stars 48 forks source link

scx_lavd: ~20% lower fps in Starcraft 2 and Diablo 3 #296

Open pingubot opened 1 month ago

pingubot commented 1 month ago

Hi,

i was testing sxc_lavd lately (after https://github.com/sched-ext/scx/issues/234 was fixed) against a linux-6.9-rcx kernel:

In Starcraft 2 and Diablo 3 i get roughly 20 percent less fps compared to eevdf. Those games are heavily using one or two cores.

Tested on: Endevaour OS Ryzen 5950x ( with one CCD disabled as the readme mentioned sxc_lavd is not optimized for more than 1 ccd cpus) 32Gb Ram

Br Pingubot

multics69 commented 1 month ago

@pingubot -- Thank you for testing scx_lavd! Could you please upload the log of lavd with ./scx_lavd -s $(nproc) for each game? I will take a look.

pingubot commented 1 month ago

@pingubot -- Thank you for testing scx_lavd! Could you please upload the log of lavd with ./scx_lavd -s $(nproc) for each game? I will take a look.

Sure thing. Still with one ccd disabled ? Simply redirect the output of that command to a file ?

vax-r commented 1 month ago

@multics69 Same issue happens for Left 4 Dead 2 on ubuntu 24.04. I use mangohud to record the FPS for EEVDF and scx_lavd , the latter provide lower "low 1% FPS" . I played 5 youtube videos on background using firefox at the same time. The CDF graph are provided below.

image image

pingubot commented 1 month ago

@multics69 I tried to get the mentioned logs and wanted to test with up2date git version but sadly i can not compile it anymore, getting the following error after doing on up2date arch with kernel 6.9:

$ cd $SCX $ meson setup build -Dbuildtype=release $ meson compile -C build scx_lavd

[pingubot@gamebox scx]$  meson compile -C build scx_lavd
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build scheds/rust/scx_lavd/Cargo.toml.__PHONY__
ninja: Entering directory `/mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build'
[1/7] Generating libbpf with a custom command
FAILED: cc_cflags_probe.c.__PHONY__ 
/mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/meson-scripts/build_libbpf /usr/bin/jq /usr/bin/make /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/libbpf/src 32
In Funktion »elf_close«,
    eingefügt von »elf_close« bei elf.c:53:6,
    eingefügt von »elf_find_func_offset_from_file« bei elf.c:384:2:
elf.c:57:9: Fehler: »elf_fd.elf« könnte uninitialisiert verwendet werden [-Werror=maybe-uninitialized]
   57 |         elf_end(elf_fd->elf);
      |         ^~~~~~~~~~~~~~~~~~~~
elf.c: In Funktion »elf_find_func_offset_from_file«:
elf.c:377:23: Anmerkung: »elf_fd.elf« wurde hier deklariert
  377 |         struct elf_fd elf_fd;
      |                       ^~~~~~
In Funktion »elf_close«,
    eingefügt von »elf_close« bei elf.c:53:6,
    eingefügt von »elf_find_func_offset_from_file« bei elf.c:384:2:
elf.c:58:9: Fehler: »elf_fd.fd« könnte uninitialisiert verwendet werden [-Werror=maybe-uninitialized]
   58 |         close(elf_fd->fd);
      |         ^~~~~~~~~~~~~~~~~
elf.c: In Funktion »elf_find_func_offset_from_file«:
elf.c:377:23: Anmerkung: »elf_fd.fd« wurde hier deklariert
  377 |         struct elf_fd elf_fd;
      |                       ^~~~~~
Auf höchster Ebene:
cc1: Anmerkung: Unbekannte Kommandozeilenoption »-Wno-unknown-warning-option« könnte den Zweck haben, bisherige Diagnosemeldungen zu unterdrücken
cc1: Alle Warnungen werden als Fehler behandelt
make: *** [Makefile:133: staticobjs/elf.o] Fehler 1
make: *** Es wird auf noch nicht beendete Prozesse gewartet …
libbpf.c: In Funktion »bpf_map__init_kern_struct_ops«:
libbpf.c:1107:18: Fehler: »mod_btf« könnte uninitialisiert verwendet werden [-Werror=maybe-uninitialized]
 1107 |         kern_btf = mod_btf ? mod_btf->btf : obj->btf_vmlinux;
      |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libbpf.c:1092:28: Anmerkung: »mod_btf« wurde hier deklariert
 1092 |         struct module_btf *mod_btf;
      |                            ^~~~~~~
In Funktion »find_struct_ops_kern_types«,
    eingefügt von »bpf_map__init_kern_struct_ops« bei libbpf.c:1100:8:
libbpf.c:980:21: Fehler: »btf« könnte uninitialisiert verwendet werden [-Werror=maybe-uninitialized]
  980 |         kern_type = btf__type_by_id(btf, kern_type_id);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libbpf.c: In Funktion »bpf_map__init_kern_struct_ops«:
libbpf.c:965:21: Anmerkung: »btf« wurde hier deklariert
  965 |         struct btf *btf;
      |                     ^~~
Auf höchster Ebene:
cc1: Anmerkung: Unbekannte Kommandozeilenoption »-Wno-unknown-warning-option« könnte den Zweck haben, bisherige Diagnosemeldungen zu unterdrücken
cc1: Alle Warnungen werden als Fehler behandelt
make: *** [Makefile:133: staticobjs/libbpf.o] Fehler 1
[2/7] Generating bpftool_target with a custom command
FAILED: bpftool_dummy.c.__PHONY__ 
/bin/bash /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/meson-scripts/build_bpftool /usr/bin/jq /usr/bin/make /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/bpftool/src 32
libbpf.c: In Funktion »bpf_object__gen_loader«:
libbpf.c:8994:28: Fehler: die Größe von »calloc« ist mit »sizeof« im früheren Argument angegeben, sollte aber im späteren stehen [-Werror=calloc-transposed-args]
 8994 |         gen = calloc(sizeof(*gen), 1);
      |                            ^
libbpf.c:8994:28: Anmerkung: das frühere Argument sollte die Anzahl der Elemente angeben, das spätere Argument die Größe des einzelnen Elements
libbpf.c: In Funktion »bpf_object__gen_loader«:
libbpf.c:8994:28: Fehler: die Größe von »calloc« ist mit »sizeof« im früheren Argument angegeben, sollte aber im späteren stehen [-Werror=calloc-transposed-args]
 8994 |         gen = calloc(sizeof(*gen), 1);
      |                            ^
libbpf.c:8994:28: Anmerkung: das frühere Argument sollte die Anzahl der Elemente angeben, das spätere Argument die Größe des einzelnen Elements
Auf höchster Ebene:
cc1: Anmerkung: Unbekannte Kommandozeilenoption »-Wno-unknown-warning-option« könnte den Zweck haben, bisherige Diagnosemeldungen zu unterdrücken
cc1: Alle Warnungen werden als Fehler behandelt
make[1]: *** [Makefile:133: /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/bpftool/src/libbpf/staticobjs/libbpf.o] Fehler 1
make: *** [Makefile:44: /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/bpftool/src/libbpf/libbpf.a] Fehler 2
make: *** Es wird auf noch nicht beendete Prozesse gewartet …
Auf höchster Ebene:
cc1: Anmerkung: Unbekannte Kommandozeilenoption »-Wno-unknown-warning-option« könnte den Zweck haben, bisherige Diagnosemeldungen zu unterdrücken
cc1: Alle Warnungen werden als Fehler behandelt
make[1]: *** [Makefile:133: /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/bpftool/src/bootstrap/libbpf/staticobjs/libbpf.o] Fehler 1
make: *** [Makefile:52: /mnt/DATA/homes/pingubot_home_data_onraid/Downloads/scx/build/bpftool/src/bootstrap/libbpf/libbpf.a] Fehler 2
ninja: build stopped: subcommand failed.

Compiling worked fine last time i tried, so something changed.

Any ideas ?

Br, Pingubit

ptr1337 commented 1 month ago

@pingubot You need to disable werror. Passt to the options: -D werror=false

multics69 commented 1 month ago

@vax-r Does Left 4 Dead 2 also heavily use 1-2 CPUs?

pingubot commented 1 month ago

@multics69 Attached find first round of logs with both ccds enabled. I was in game in campaign in d3 and sc2 for half a minute or less before leaving the game again. Hope thats enough time.

Tested with: Linux 6.9-tkg, amd_pstate=active Commit: 17c0c10b4efbfe9819ba818396b1c3438fc7e45c

What i did: Start battlenet Start lavd Start d3 game Stop d3 game Stop lavd start lavd Start sc2 game Stop sc2 game stop lavd

2 CCD Logs: d3_lavd_2ccd.log

sc2_lavd_2ccd.log

1 CCD logs: d3_lavd_1ccd.log

sc2_lavd_1ccd.log

Will attached the logs for 1 ccd enabled in a few mins. Edit: logs with 1 ccd attached.

Many thx Pingubot

vax-r commented 1 month ago

@vax-r Does Left 4 Dead 2 also heavily use 1-2 CPUs?

I'll check it out tomorrow, the testing machine isn't nearby me currently.

multics69 commented 1 month ago

Thanks @pingubot for sharing the logs. I am investigating them now.

pingubot commented 1 month ago

Thanks @pingubot for sharing the logs. I am investigating them now.

Very nice ! For Sc2 there is even a free version if you want to test it on your pc.

multics69 commented 1 month ago

@pingubot -- I didn't know that there is a free version. Could you let me know more details of your software environment -- Wine, etc?

pingubot commented 1 month ago

@pingubot -- I didn't know that there is a free version. Could you let me know more details of your software environment -- Wine, etc?

Sure thing, sorry for my late reply, missed the notification mail:

I am using Proton Experimental for sc2 and d3. You can do that by adding battle.net as a third party application to the steam library.

OS: EndeavourOS (Arch) Kernel: 6.9.x TKG DE: Plasma 6 on wayland Mesa: What is up2date in arch

Br, Pingubot

vax-r commented 1 month ago

@multics69 EEVDF is the one heavily uses 1~2 CPU on Left 4 Dead 2 , before I use stress-ng --cpu 12 --timeout 60 the CPU load seems to be heavily unbalanced. However , after I turn ran stress-ng test during the game for 1 minute , I can't really see the difference between EEVDF and LAVD scheduler from the perspective of the CPU load .

I do the following test

// for EEVDF scheduler
open Left 4 Dead 2
start MangoHud logging
start stress-ng test
start huge batches of I/O bound tasks
start playing for 1 minute
stop MangoHud logging

// for LAVD scheduler
start scx service
open Left 4 Dead 2
start MangoHud logging
start stress-ng test
start huge batches of I/O bound tasks
start playing for 1 minute
stop MangoHud logging
stop scx service

The result of FPS and CPU load shows below eevdf-ginsight-cpu_load eevdf-ginsight-fps scx_lavd-ginsight-cpu_load scx_lavd-ginsight-fps

vax-r commented 1 month ago

You can see the low 1% FPS is better in EEVDF , when all CPU loads are 100% I don't know how to check whether the scheduler or the game heavily uses 1~2 CPU or not

vax-r commented 1 month ago

@multics69 - I utitlize mpstat -P ALL 1 120 and analyze the log to see the maximum load difference between diferent processors, running Left 4 Dead 2 and I/O-intensive work in the background . The result shows that the maximum CPU load difference for EEVDF is 52.48% , and the maximum CPU load difference for scx_lavd is only 19.92%. I don't think scx_lavd heavily uses paritcular CPUs.

multics69 commented 1 month ago

Thank you for sharing the details @vax-r. I am preparing a patch set to address what you mentioned. I will let you know things are ready from my side.

Pogogo007 commented 3 weeks ago

Looking forward to the patch set as well

multics69 commented 3 weeks ago

@Pogogo007 Can you share your use-case (if have)? That will help me to narrow down the problem.

multics69 commented 3 weeks ago

@vax-r in you new experiment, did you use the version with PR #338 ?

Pogogo007 commented 3 weeks ago

@Pogogo007 Can you share your use-case (if have)? That will help me to narrow down the problem.

I personally have not done many tests on it. However currently we ship it on CachyOS's experimental handheld edition. many users have reported laggy desktop and generally quite lower framerate than expected. Some of our users have posted benchmarks compared to other schedulers on our discord. Most of our users currently use either a steam deck or an ROG ally

vax-r commented 3 weeks ago

@vax-r in you new experiment, did you use the version with PR #338 ?

Nope, I tested it on v6.7 kernel . I'll test it on v6.9.3 later with PR #338

multics69 commented 3 weeks ago

@Pogogo007 Do you have a forum or discord so I can dig up more information?

multics69 commented 3 weeks ago

@pingubot Could you try the LAVD on the main (with PR #338)? The side-effect of PR #338 is running fewer cores in a higher clock frequency. I personally failed to install SC2. :-(

Pogogo007 commented 3 weeks ago

@Pogogo007 Do you have a forum or discord so I can dig up more information?

Yes the discord is https://discord.gg/cachyos-862292009423470592 more specifically in the #handheld-edition channel and our forums are discuss.cachyos.org

pingubot commented 2 weeks ago

@pingubot Could you try the LAVD on the main (with PR #338)? The side-effect of PR #338 is running fewer cores in a higher clock frequency. I personally failed to install SC2. :-(

Did with both ccds on and its 300fps (lavd) vs 380fps (6..9.4 linux-tkg cfs) in Diablo 3. Will test with only one ccd at the we. Installing Starcraft 2 should be straight forward. Download bnet app and add it as a third party game to Steam and then install starcraft their. Or use lutris or something like that which might have an automated way to install it and use wine instead of proton.