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

I[Idea/Question] Cross-compile a bench test to run on a remote target? #736

Open
RaulTrombin opened this issue Oct 25, 2023 · 4 comments
Open

Comments

@RaulTrombin
Copy link

I'm using criterion to run bench on a raspberry pi4 target, but compile it from zero there takes 21 minutes.
Someone already tryed to cross compile the required stuff and then execute from the target?

@steckes
Copy link

steckes commented Apr 25, 2024

Hey!
Yes I just did it, so I will explain you how:

  1. I use cross to cross compile the project.
  2. For Raspberry Pi I compile the benchmark with
cross bench --target aarch64-unknown-linux-gnu
  1. The benchmark will run now in the docker container, so ignore the printed results. But the benchmark will print which binary it runs, for me it looks like this
/target/aarch64-unknown-linux-gnu/release/deps/my_bench-7dfs8993ds789 --bench
  1. now copy the binary on your raspberry pi eg. with scp
scp /target/aarch64-unknown-linux-gnu/release/deps/my_bench-7dfs8993ds789 pi@<ip_address>:/home/pi/my_bench
  1. ssh onto the pi and run the benchmark
./my_bench --bench

(You could also specify the target CPU to eventually speed things up, just put before cross bench ...: RUSTFLAGS='-C target-cpu=cortex-a72')

@RaulTrombin
Copy link
Author

@stexa thks! Will try this on my runners,
I also found a --no-run option for cargo bench docs, will try mix both and see if it works.

@RaulTrombin
Copy link
Author

RaulTrombin commented Nov 24, 2024

Thanks @steckes,
Added option to use bench on action-rust-cross,

which now allow us to:

  cross-compile-bench:
      needs: build
      if: ${{ github.repository_owner == 'bluerobotics' }}
      runs-on: ubuntu-latest
      strategy:
        matrix:
          TARGET: [armv7-unknown-linux-gnueabihf]
      steps:
      - uses: actions/checkout@master
      - name: Cross-compile benchmark
        uses: houseabsolute/[email protected]
        with:
          command: bench
          target: ${{ matrix.TARGET }}
          args: "--no-run"
      - name: Upload benchmark binary
        uses: actions/[email protected]
        with:
          name: benchmark-binary
          path: target/${{ matrix.TARGET }}/release/deps/bench-*
          retention-days: 1

  run-bench:
    needs: cross-compile-bench
    runs-on: raspbian-armv7-kernel-5.10.33
    steps:
    - uses: actions/checkout@master
    - name: Download benchmark binary
      uses: actions/[email protected]
      with:
        name: benchmark-binary
        path: ./bench-binary
    - name: Make benchmark executable
      run: |
        chmod +x ./bench-binary/*
    - name: Run benchmark
      run: |
        BENCH_BINARY=$(find ./bench-binary -type f -executable -name "bench-*" -not -name "*.d" | head -n 1)
        "$BENCH_BINARY" --bench --output-format bencher | tee output.txt || { echo "Basic benchmark failed"; exit 1; }

New benchmarking whole process reduces from 25 min to just 7 minutes.

@RaulTrombin
Copy link
Author

@bheisler I think we can close this issue, & maybe can we document it somewhere?

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

No branches or pull requests

2 participants