ilya-zlobintsev / LACT

Linux AMDGPU Configuration Tool
MIT License
1.14k stars 30 forks source link

[Looking for user feedback] Add support for per-application config profiles #251

Open ilya-zlobintsev opened 7 months ago

ilya-zlobintsev commented 7 months ago

It would be nice if it was possible to create multiple config profiles, and automatically switch them based on currently running applications. An example use case would be to have one set of settings when you're running a specific game, another when you're running a compute workload etc.

If you're a user and you would find this feature useful, please say so.

Implementation details: ideally this would be done via a eBPF plugin that subscribes to process start/exit events. bpftrace examples:

bpftrace -e 'tracepoint:syscalls:sys_enter_exec* { printf("SPAWN %d ", pid); join(args.argv); }'
bpftrace -e 'tracepoint:sched:sched_process_exit { printf("EXIT %d %s\n", args.pid, comm); }'

If this ends up being too difficult, another way would be to poll /proc, but need to make sure that it's not too expensive to do so

43615 commented 7 months ago

I'm not sure if I'd use this myself, but it would definitely be a nice bonus feature once full baseline support is there.

For a solid implementation, I'm thinking of a priority-based system (short-circuiting check down a list of conditions with associated profiles). The conditions could be simple checks for the presence of certain processes, maybe with the additional option of setting a custom command and matching on its exit code. Seems easy enough to implement with sysinfo and std::process. I'm not a fan of using start/stop events since the daemon would forget the current state when restarted. Instead, I propose checking the conditions on a timer (every few seconds?). Any application that misbehaves when the parameters change would do so either way.

ilya-zlobintsev commented 7 months ago

The problem with scanning the process list every few seconds is that it requires scanning the entire /proc filesystem, which might be a relatively heavy operation. Currently the LACT daemon is very lightweight and doesn't do anything unless it actually needs to, and I'd like to keep it that way considering it's something that always runs in the background. The full scan would still need to be done on service startup to keep track of already existing processes though.

ilya-zlobintsev commented 7 months ago

Reference for self on how other projects do it:

In-line commented 6 months ago

Gamemode support is only thing needed

FabianoIlCapo commented 4 months ago

It would be nice if it was possible to create multiple config profiles, and automatically switch them based on currently running applications. An example use case would be to have one set of settings when you're running a specific game, another when you're running a compute workload etc.

Sounds like the equivalent of what the Nvidia control panel does (or did), that would be GOLDEN!

Umio-Yasuno commented 4 months ago

I am developing a simple amdgpu profile switcher.
Some changes are required, but that tool could be used for LACT.

https://github.com/Umio-Yasuno/amdgpu-profile-switcher

bioxz commented 4 months ago

I would love to see this. I don't care about automatic switching, as I like to switch the profiles by hand even using the same application. I have a default undervolted and underclocked mode which allows me to use the GPU without its fans and a overclocked mode which is quite noisy, basically silent just using case fans.

Currently I'm using corectl which (in my eyes) does the whole profile thing in a weird and over complicated way (you can have multiple profiles active at once, partly overwriting others). Biggest "issue" right now is that you cannot ask the command line tool which profile is active, so you have to rely on the GUI to switch profiles.

Having a command/API to simply active a profile and another to request the current profile would be perfect, so I can build interfaces for a Plasma Widget and my Stream Deck.