Skip to content

Execute benchmarks as current user - #308

Open
smarr wants to merge 7 commits into
masterfrom
benchmark-as-current-user
Open

Execute benchmarks as current user#308
smarr wants to merge 7 commits into
masterfrom
benchmark-as-current-user

Conversation

@smarr

@smarr smarr commented Sep 4, 2026

Copy link
Copy Markdown
Owner

The main goal of the PR is to ensure that benchmarks are run with the current user.
Before, when we use denoise, we'd end up running with root. Now, we return back to the initial user and execute the benchmarks as that one.

The core change is thus, to add a sudo -u $currentUser to the command line that executes the benchmark.
Though to make this work, we need a few more changes:

  • use env -i to create an empty environment in $currentUser, and only set the vars we want
  • pass command line as a list of strings instead of a single string interpreted by a shell. This is needed to make sure the env var values are not wrongly escaped
  • I renamed cmdline to cmd in places where it's now a list[str]. We keep it as a str until all ReBench variables are replaced during preparing the cmdline when creating the runs.
  • fix how we determine the current user. Use geteuid() and getpwuid() to avoid picking up stale env vars with the users name. This was an issue on macOS.

Added tests:

  • end-to-end check of env vars a benchmark sees
  • end-to-end check of which user the benchmark is executed with
  • end-to-end integration test, which checks rebench, and our denoise abilities, too (note, the results are currently machine specific, and will need to be updated over time)

@flohuemer, since you proposed the initial change, could you give this a read/review? Thanks!

flohuemer and others added 7 commits September 3, 2026 15:37
Instead of running the benchmarks as root, switch to the user running rebench.

Co-authored-by: Florian Huemer <florian.huemer@jku.at>
Co-authored-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
 - test for the machine capabilities and end-to-end behavior
 - test that environment variables as passed through to the benchmark

Signed-off-by: Stefan Marr <git@stefan-marr.de>
- this is only so after all variable replacement has been done
- do not run benchmark command in a shell anymore, since it’s not supported with string lists

Signed-off-by: Stefan Marr <git@stefan-marr.de>
- cmdline feels now a bit misleading

Signed-off-by: Stefan Marr <git@stefan-marr.de>
- do not need to preserve env anymore, since we create it explicitly
- remove PYTHONPATH from perserved env vars. It seesm to work without
- and we do not need SETENV capability anymore

Signed-off-by: Stefan Marr <git@stefan-marr.de>
This is expected to be more consistent since getuser() may use envvars, which seem problematic when the gitlab runner runs on macOS, where it sees a stale “root” user, even though the effective user is gitlab-runner.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants