Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebench doesn't search the path correctly #247

Closed
vext01 opened this issue Aug 2, 2024 · 11 comments · Fixed by #248
Closed

rebench doesn't search the path correctly #247

vext01 opened this issue Aug 2, 2024 · 11 comments · Fixed by #248

Comments

@vext01
Copy link
Contributor

vext01 commented Aug 2, 2024

Hi Stefan,

I have a config file where the executors have no path directive, like:

executors:
    Lua:
        executable: lua
    YkLua:
        executable: yklua

The docs say:

Path to the executable. If not given, it's up to the shell to find the executable.

So I'd expect the shell to search $PATH.

Here's a snippet of a CI script I'm writing:

...
# Do a "quick" rebench run as a smoke-test.
pipx install rebench
export PATH=$(pwd)/yklua/src:${PATH}
which lua
which yklua
~/.local/bin/rebench --quick --no-denoise -c rebench.conf

I added the which invocations to prove to myself that the lua and yklua binaries are in $PATH.

Here's the output (when the shell has set -x):

+ export PATH=/ci/yklua/src:/ci/yk/bin:/ci/.cargo/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ which lua
/ci/yklua/src/lua
+ which yklua
/ci/yklua/src/yklua
+ /home/ci/.local/bin/rebench --quick --no-denoise -c rebench.conf
Running Benchmarks: 0.00%

Executing run:Permute (Lua, awfy, 1000) default None None None
    cmd: lua  harness.lua Permute 1  1000
    cwd: /ci/awfy/Lua
    Error: Could not execute Lua.
        The command was not found.
    Return code: 127
        /bin/sh: 1: lua: not found.
    Aborting remaining benchmarks using lua.Running Benchmarks:                                      Permute (Lua, awfy, 1000) default       mean:        0.0        time
left: 00:00:00: 50.00%

Executing run:Storage (YkLua, awfy, 1000) default None None None
    cmd: yklua  harness.lua Storage 1  1000
    cwd: /ci/awfy/Lua
    Error: Could not execute YkLua.
        The command was not found.
    Return code: 127
        /bin/sh: 1: yklua: not found.
    Aborting remaining benchmarks using yklua.Running Benchmarks:                                    Storage (YkLua, awfy, 1000) default     mean:        0.0        time

The which invocations find the interpreter binaries, but rebench doesn't.

Is it possible rebench isn't searching the path properly?

Cheers

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

Sorry, ReBench runs everything in an empty environment...

So, this means you'll need to configure the PATH variable in your configuration.

The one important immediate improvement would be to fix the docs to point to the semantics of environment variables: you'll need to manage them yourself. All in an effort to have configurations are reproducible as possible. But perhaps we went a little far with it...

See for previous discussions and details:

@vext01
Copy link
Contributor Author

vext01 commented Aug 2, 2024

I see.

Yes, that is unexpected and it did catch me off guard a bit.

I can work around it by requiring the user to symlink their interpreter binaries into (e.g.) bin/ and adding path: bin into the config file.

If you don't want to pass $PATH through, one thing you could do to fix this is: before any experiments are run, resolve absolute paths for all the executors that don't have a path directive using the existing PATH (or crash if you can't) and then run the interpreters using absolute paths and an empty environment. (In addition, if you can resolve all executors to an absolute path, you could invoke the interpreters without a shell).

I dunno, just an idea.

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

How about something like this:

executors:
    Lua:
        executable: lua
        env:
           PATH: /opt/local/bin

Also note that we try to resolve ~ in the commands (not in env variables though) to avoid having configurations to be too specific to a machine: #240

@vext01
Copy link
Contributor Author

vext01 commented Aug 2, 2024

IIRC, you can already acheive that effect with:

executors:
    Lua:
        executable: lua
        path: /opt/local/bin

I was looking for a way to do it without requiring hardcoding (potentially) machine-specific paths.

I'll leave the decision up to you, because I can certainly work around this.

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

If you don't want to pass $PATH through, one thing you could do to fix this is: before any experiments are run, resolve absolute paths for all the executors that don't have a path directive using the existing PATH (or crash if you can't) and then run the interpreters using absolute paths and an empty environment. (In addition, if you can resolve all executors to an absolute path, you could invoke the interpreters without a shell).

While this might be more user-friendly, I don't think this is in the spirit of making configurations self-contained.
This then is still depending on the undocumented environment, and one may pick up different binaries based without this being visible in the config.

@vext01
Copy link
Contributor Author

vext01 commented Aug 2, 2024

Right, so actually what you have now is probably sufficient, just the documentation needs to be updated.

Path to the executable. If not given, it's up to the shell to find the executable.

^ The second sentence is misleading

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

IIRC, you can already achieve that effect with

Yeah, the trivial example doesn't really illustrate why that's useful.
Though, when the executable itself relies on the PATH being set for something, then this is more important.

For your specific case, why not this?

executors:
    Lua:
        executable: lua
        path: yklua/src
    YkLua:
        executable: yklua
        path: yklua/src

This way, you don't rely on PATH at all.
And that's really the style we are using, too.
Assuming you don't need it in anything these things execute.

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

Right, so actually what you have now is probably sufficient, just the documentation needs to be updated.

Path to the executable. If not given, it's up to the shell to find the executable.

^ The second sentence is misleading

Yes, that's what I meant earlier with "The one important immediate improvement would be to fix the docs "

@vext01
Copy link
Contributor Author

vext01 commented Aug 2, 2024

I don't think this is in the spirit of making configurations self-contained.

One other thing that might be a little misleading is that although rebench doesn't pass down $PATH from the parent environment, it will still search the system's default paths.

For example, on my system this does work:

executors:
    Lua:
        executable: lua53

because lua53 is in /usr/local/bin, which is in the system's default $PATH.

@smarr
Copy link
Owner

smarr commented Aug 2, 2024

ReBench doesn't do anything magic, I think. So, I'd assume the system is doing this for you.

So, I am trying this very basic config here:

default_experiment: benchmarks
default_data_file: 'rebench.data'

benchmark_suites:
    test-suite:
        gauge_adapter: Time
        command: " "
        benchmarks:
            - TestBench

executors:
    exec1:
        executable: env

experiments:
    benchmarks:
        description: All benchmarks
        suites:
          - test-suite
        executions:
          - exec1

When I run it like this: rebench -d rebench-test.conf

I get:

Executing run:TestBench (exec1, test-suite) 1 None None None
    cmd: /opt/local/bin/gtime -f "max rss (kb): %M
wall-time (secounds): %e
" env
    cwd: /Users/smarr/tmp
    Starting run
PWD=/usr/bin
SHLVL=1
_=/opt/local/bin/gtime
max rss (kb): 1040
wall-time (secounds): 0.00

So, we see the environment is entirely empty, and the shell is asked to run /opt/local/bin/gtime -f "..." env" in the path /Users/smarr/tmp.

@vext01
Copy link
Contributor Author

vext01 commented Aug 2, 2024

Interesting. On my BSD box I get:

Executing run:TestBench (exec1, test-suite) 1 None None None
    cmd: /usr/bin/time -p env
    cwd: /home/edd/research/yk-benchmarks
    Starting run
PWD=/home/edd/research/yk-benchmarks
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin

On my debian box I get:

Executing run:TestBench (exec1, test-suite) 1 None None None
    cmd: /usr/bin/time -f "max rss (kb): %M
wall-time (secounds): %e
" env
    cwd: /home/vext01/research/yk-benchmarks
    Starting run
PWD=/home/vext01/research/yk-benchmarks

So I guess different systems do different things.

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 a pull request may close this issue.

2 participants