From 54ad5d3416bbef1c90b3821c27ea5c8ca3ba1aee Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 17 Oct 2022 17:40:35 +0200 Subject: [PATCH 1/6] moved benchmarks to nix --- .earthignore | 4 -- .github/workflows/benchmarks.yml | 11 ++- Earthfile | 72 ------------------- ci/{ => benchmarks}/bench-runner/Cargo.lock | 0 ci/{ => benchmarks}/bench-runner/Cargo.toml | 0 ci/{ => benchmarks}/bench-runner/src/main.rs | 4 +- ci/benchmarks/prep_folder.sh | 26 +++++++ ci/enable-lld.sh | 3 + ci/get_latest_release_url.sh | 3 + ci/package_release.sh | 4 ++ ci/safe-earthly.sh | 23 ------ ci/write_version.sh | 4 ++ ci/www-repl.sh | 3 + crates/compiler/builtins/bitcode/benchmark.sh | 1 + crates/repl_test/test_wasm.sh | 3 +- crates/repl_wasm/build-www.sh | 1 + examples/swiftui/run.sh | 3 + flake.nix | 1 + www/build.sh | 1 + www/netlify.sh | 1 + 20 files changed, 60 insertions(+), 108 deletions(-) delete mode 100644 .earthignore delete mode 100644 Earthfile rename ci/{ => benchmarks}/bench-runner/Cargo.lock (100%) rename ci/{ => benchmarks}/bench-runner/Cargo.toml (100%) rename ci/{ => benchmarks}/bench-runner/src/main.rs (97%) create mode 100755 ci/benchmarks/prep_folder.sh delete mode 100755 ci/safe-earthly.sh diff --git a/.earthignore b/.earthignore deleted file mode 100644 index a291dd2885..0000000000 --- a/.earthignore +++ /dev/null @@ -1,4 +0,0 @@ -AUTHORS -nix -.envrc -.gitignore \ No newline at end of file diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 58e0ee422c..63566e54f6 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -23,25 +23,24 @@ jobs: ref: "main" clean: "true" - - name: Earthly version - run: earthly --version + - run: alias nix=/home/big-ci-user/.nix-profile/bin/nix - name: on main; prepare a self-contained benchmark folder - run: ./ci/safe-earthly.sh --build-arg BENCH_SUFFIX=main +prep-bench-folder + run: nix develop -c ./ci/benchmarks/prep_folder.sh main - uses: actions/checkout@v3 with: clean: "false" # we want to keep the benchmark folder - name: on current branch; prepare a self-contained benchmark folder - run: ./ci/safe-earthly.sh +prep-bench-folder + run: nix develop -c ./ci/benchmarks/prep_folder.sh branch - uses: actions-rs/toolchain@v1 with: toolchain: stable - name: build benchmark runner - run: cd ci/bench-runner && cargo build --release && cd ../.. + run: nix develop -c `cd ci/bench-runner && cargo build --release && cd ../..` - name: run benchmarks with regression check - run: ./ci/bench-runner/target/release/bench-runner --check-executables-changed + run: nix develop -c ./ci/bench-runner/target/release/bench-runner --check-executables-changed diff --git a/Earthfile b/Earthfile deleted file mode 100644 index 7c59196695..0000000000 --- a/Earthfile +++ /dev/null @@ -1,72 +0,0 @@ -FROM rust:1.61.0-slim-bullseye # make sure to update rust-toolchain.toml too so that everything uses the same rust version -WORKDIR /earthbuild - -prep-debian: - RUN apt -y update - -install-other-libs: - FROM +prep-debian - RUN apt -y install wget git - RUN apt -y install libxcb-shape0-dev libxcb-xfixes0-dev # for editor clipboard - RUN apt -y install libasound2-dev # for editor sounds - RUN apt -y install libunwind-dev pkg-config libx11-dev zlib1g-dev - RUN apt -y install unzip # for www/build.sh - -install-zig-llvm-valgrind: - FROM +install-other-libs - # editor - RUN apt -y install libxkbcommon-dev - # zig - RUN wget -c https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz --no-check-certificate - RUN tar -xf zig-linux-x86_64-0.9.1.tar.xz - RUN ln -s /earthbuild/zig-linux-x86_64-0.9.1/zig /bin/zig - # zig builtins wasm tests - RUN apt -y install build-essential - RUN cargo install wasmer-cli --features "singlepass" - RUN cargo install bindgen - # llvm - RUN apt -y install lsb-release software-properties-common gnupg - RUN wget https://apt.llvm.org/llvm.sh - RUN chmod +x llvm.sh - RUN ./llvm.sh 13 - RUN ln -s /usr/bin/clang-13 /usr/bin/clang - # use lld as linker - RUN ln -s /usr/bin/lld-13 /usr/bin/ld.lld - ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld -C target-cpu=native" - # valgrind - RUN apt -y install valgrind - # wasm repl & tests - RUN rustup target add wasm32-unknown-unknown wasm32-wasi - RUN apt -y install libssl-dev - RUN OPENSSL_NO_VENDOR=1 cargo install wasm-pack - # criterion - RUN cargo install cargo-criterion - # sccache - RUN cargo install sccache - RUN sccache -V - ENV RUSTC_WRAPPER=/usr/local/cargo/bin/sccache - ENV SCCACHE_DIR=/earthbuild/sccache_dir - ENV CARGO_INCREMENTAL=0 # no need to recompile package when using new function - -copy-dirs: - FROM +install-zig-llvm-valgrind - COPY --dir crates Cargo.toml Cargo.lock version.txt www ./ - -# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run. -prep-bench-folder: - FROM +copy-dirs - # to make use of avx, avx2, sse2, sse4.2... instructions - ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld -C target-cpu=native" - ARG BENCH_SUFFIX=branch - RUN cargo criterion -V - RUN --mount=type=cache,target=$SCCACHE_DIR cd crates/cli && cargo criterion --no-run - RUN mkdir -p bench-folder/crates/cli_testing_examples/benchmarks - RUN mkdir -p bench-folder/crates/compiler/builtins/bitcode/src - RUN mkdir -p bench-folder/target/release/deps - RUN cp crates/cli_testing_examples/benchmarks/*.roc bench-folder/crates/cli_testing_examples/benchmarks/ - RUN cp -r crates/cli_testing_examples/benchmarks/platform bench-folder/crates/cli_testing_examples/benchmarks/ - RUN cp crates/compiler/builtins/bitcode/src/str.zig bench-folder/crates/compiler/builtins/bitcode/src - RUN cp target/release/roc bench-folder/target/release - # copy the most recent time bench to bench-folder - RUN cp target/release/deps/`ls -t target/release/deps/ | grep time_bench | head -n 1` bench-folder/target/release/deps/time_bench - SAVE ARTIFACT bench-folder AS LOCAL bench-folder-$BENCH_SUFFIX diff --git a/ci/bench-runner/Cargo.lock b/ci/benchmarks/bench-runner/Cargo.lock similarity index 100% rename from ci/bench-runner/Cargo.lock rename to ci/benchmarks/bench-runner/Cargo.lock diff --git a/ci/bench-runner/Cargo.toml b/ci/benchmarks/bench-runner/Cargo.toml similarity index 100% rename from ci/bench-runner/Cargo.toml rename to ci/benchmarks/bench-runner/Cargo.toml diff --git a/ci/bench-runner/src/main.rs b/ci/benchmarks/bench-runner/src/main.rs similarity index 97% rename from ci/bench-runner/src/main.rs rename to ci/benchmarks/bench-runner/src/main.rs index 44d7e1c027..38afcd801d 100644 --- a/ci/bench-runner/src/main.rs +++ b/ci/benchmarks/bench-runner/src/main.rs @@ -51,8 +51,8 @@ fn main() { eprintln!( r#"I can't find bench-folder-main and bench-folder-branch from the current directory. I should be executed from the repo root. - Use `./ci/safe-earthly.sh --build-arg BENCH_SUFFIX=main +prep-bench-folder` to generate bench-folder-main. - Use `./ci/safe-earthly.sh +prep-bench-folder` to generate bench-folder-branch."# + Use `./ci/benchmarks/prep_folder.sh main` to generate bench-folder-main. + Use `./ci/benchmarks/prep_folder.sh branch` to generate bench-folder-branch."# ); process::exit(1) diff --git a/ci/benchmarks/prep_folder.sh b/ci/benchmarks/prep_folder.sh new file mode 100755 index 0000000000..926c000cc5 --- /dev/null +++ b/ci/benchmarks/prep_folder.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run. + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + +# to make use of avx, avx2, sse2, sse4.2... instructions +RUSTFLAGS="-C link-arg=-fuse-ld=lld -C target-cpu=native" +BENCH_SUFFIX=$1 + +cargo criterion -V +cd crates/cli && cargo criterion --no-run && cd ../.. +mkdir -p bench-folder/crates/cli_testing_examples/benchmarks +mkdir -p bench-folder/crates/compiler/builtins/bitcode/src +mkdir -p bench-folder/target/release/deps +mkdir -p bench-folder/target/release/lib +cp "crates/cli_testing_examples/benchmarks/"*".roc" bench-folder/crates/cli_testing_examples/benchmarks/ +cp -r crates/cli_testing_examples/benchmarks/platform bench-folder/crates/cli_testing_examples/benchmarks/ +cp crates/compiler/builtins/bitcode/src/str.zig bench-folder/crates/compiler/builtins/bitcode/src +cp target/release/roc bench-folder/target/release +cp -r target/release/lib bench-folder/target/release + +# copy the most recent time bench to bench-folder +cp target/release/deps/`ls -t target/release/deps/ | grep time_bench | head -n 1` bench-folder/target/release/deps/time_bench +mv bench-folder bench-folder-$BENCH_SUFFIX \ No newline at end of file diff --git a/ci/enable-lld.sh b/ci/enable-lld.sh index 04377329b6..4567172783 100755 --- a/ci/enable-lld.sh +++ b/ci/enable-lld.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + mkdir -p $HOME/.cargo echo -e "[build]\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\", \"-C\", \"target-cpu=native\"]" > $HOME/.cargo/config diff --git a/ci/get_latest_release_url.sh b/ci/get_latest_release_url.sh index 4fc7f2383d..3d8e5f26b5 100755 --- a/ci/get_latest_release_url.sh +++ b/ci/get_latest_release_url.sh @@ -2,6 +2,9 @@ # assumes roc_releases.json is present +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + LATEST_RELEASE_URL=`cat roc_releases.json | jq --arg arch $1 --arg today $(date +'%Y-%m-%d') '.[0] | .assets | map(.browser_download_url) | map(select(. | contains("\($arch)-\($today)"))) | .[0]'` if [[ "$LATEST_RELEASE_URL" == "null" ]] diff --git a/ci/package_release.sh b/ci/package_release.sh index 4c03da969e..1bd7cf34c2 100755 --- a/ci/package_release.sh +++ b/ci/package_release.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + cp target/release/roc ./roc # to be able to exclude "target" later in the tar command cp -r target/release/lib ./lib tar -czvf $1 --exclude="target" --exclude="zig-cache" roc lib LICENSE LEGAL_DETAILS examples/helloWorld.roc examples/cli crates/roc_std diff --git a/ci/safe-earthly.sh b/ci/safe-earthly.sh deleted file mode 100755 index 0ddc13c5c0..0000000000 --- a/ci/safe-earthly.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -LOG_FILE="earthly_log.txt" -touch $LOG_FILE - -# first arg + everything after -ARGS=${@:1} -FULL_CMD="earthly --config ci/earthly-conf.yml $ARGS" -echo $FULL_CMD -script -efq $LOG_FILE -c "$FULL_CMD" -EXIT_CODE=$? - -if grep -q "failed to mount" "$LOG_FILE"; then - echo "" - echo "" - echo "------<<<<<>>>>>------" - echo "DETECTED FAILURE TO MOUNT ERROR: running without cache" - echo "------<<<<<>>>>>------" - echo "" - echo "" - earthly --config ci/earthly-conf.yml --no-cache $ARGS -else - exit $EXIT_CODE -fi diff --git a/ci/write_version.sh b/ci/write_version.sh index 36ec1e9ffb..8e6f99fdc7 100755 --- a/ci/write_version.sh +++ b/ci/write_version.sh @@ -1,3 +1,7 @@ #!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + # version.txt is used by the CLI: roc --version printf 'nightly pre-release, built from commit ' > version.txt && git log --pretty=format:'%h' -n 1 >> version.txt && printf ' on ' >> version.txt && date -u >> version.txt \ No newline at end of file diff --git a/ci/www-repl.sh b/ci/www-repl.sh index 221b708947..1cacbbaacc 100755 --- a/ci/www-repl.sh +++ b/ci/www-repl.sh @@ -1,3 +1,6 @@ #!/usr/bin/env bash +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + crates/repl_wasm/build-www.sh `pwd`/roc_repl_wasm.tar.gz diff --git a/crates/compiler/builtins/bitcode/benchmark.sh b/crates/compiler/builtins/bitcode/benchmark.sh index ae6ff3297b..410188d451 100755 --- a/crates/compiler/builtins/bitcode/benchmark.sh +++ b/crates/compiler/builtins/bitcode/benchmark.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euxo pipefail zig build-exe benchmark/dec.zig -O ReleaseFast --main-pkg-path . diff --git a/crates/repl_test/test_wasm.sh b/crates/repl_test/test_wasm.sh index 08a49a8d31..506d98501c 100755 --- a/crates/repl_test/test_wasm.sh +++ b/crates/repl_test/test_wasm.sh @@ -1,4 +1,5 @@ -set -eux +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail # Build the compiler for WebAssembly target # We *could* write a build.rs to do this but we'd have nested cargo processes with different targets. diff --git a/crates/repl_wasm/build-www.sh b/crates/repl_wasm/build-www.sh index a2f8afd761..bc439e05aa 100755 --- a/crates/repl_wasm/build-www.sh +++ b/crates/repl_wasm/build-www.sh @@ -8,6 +8,7 @@ # Our website deployment script downloads that zipfile and copies the files into www/build/repl/ # We use this two-step process because Netlify times out if we try to build the Web REPL there. +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euxo pipefail if ! which wasm-pack diff --git a/examples/swiftui/run.sh b/examples/swiftui/run.sh index 9a3eb2f430..d20a18d314 100755 --- a/examples/swiftui/run.sh +++ b/examples/swiftui/run.sh @@ -1,5 +1,8 @@ #! /usr/bin/env bash +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + cargo run -- build mkdir -p SwiftUIDemo.app/Contents/MacOS/ mv swiftui SwiftUIDemo.app/Contents/MacOS/SwiftUIDemo diff --git a/flake.nix b/flake.nix index 83ebc1647f..b5ac467669 100644 --- a/flake.nix +++ b/flake.nix @@ -105,6 +105,7 @@ debugir rust rust-bindgen + cargo-criterion ]); in { diff --git a/www/build.sh b/www/build.sh index 6797db6467..bbc1a67c77 100755 --- a/www/build.sh +++ b/www/build.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euxo pipefail # cd into the directory where this script lives. diff --git a/www/netlify.sh b/www/netlify.sh index 43aa6c01b6..165a70bceb 100644 --- a/www/netlify.sh +++ b/www/netlify.sh @@ -2,6 +2,7 @@ # Runs on every Netlify build, to set up the Netlify server. +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euxo pipefail rustup update From 0ea9a2a524001ede819d857df6fa8c75a9dc00e9 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:21:39 +0200 Subject: [PATCH 2/6] moved to shorter nix command --- .github/workflows/benchmarks.yml | 2 -- .github/workflows/nix_linux_x86_64.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 63566e54f6..39a605ade6 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -23,8 +23,6 @@ jobs: ref: "main" clean: "true" - - run: alias nix=/home/big-ci-user/.nix-profile/bin/nix - - name: on main; prepare a self-contained benchmark folder run: nix develop -c ./ci/benchmarks/prep_folder.sh main diff --git a/.github/workflows/nix_linux_x86_64.yml b/.github/workflows/nix_linux_x86_64.yml index 17e8e0a013..b786a6d431 100644 --- a/.github/workflows/nix_linux_x86_64.yml +++ b/.github/workflows/nix_linux_x86_64.yml @@ -20,4 +20,4 @@ jobs: clean: "true" - name: execute tests with --release - run: /home/big-ci-user/.nix-profile/bin/nix develop -c cargo test --locked --release + run: nix develop -c cargo test --locked --release From e8e46c9e26a3b494293b0697340fb67a3447e9c0 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 18 Oct 2022 14:23:59 +0200 Subject: [PATCH 3/6] disable main checkout Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/benchmarks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 39a605ade6..b79c619f46 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: "main" + # ref: "main" # TODO set this to main once merged, can't do this now because main does not yet have the right files. clean: "true" - name: on main; prepare a self-contained benchmark folder From c3e48db5077a52040597d38b662c26c73003a5c5 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:03:45 +0200 Subject: [PATCH 4/6] fix path Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/benchmarks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b79c619f46..68d234722e 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -38,7 +38,7 @@ jobs: toolchain: stable - name: build benchmark runner - run: nix develop -c `cd ci/bench-runner && cargo build --release && cd ../..` + run: nix develop -c `cd ci/benchmarks/bench-runner && cargo build --release && cd ../../..` - name: run benchmarks with regression check - run: nix develop -c ./ci/bench-runner/target/release/bench-runner --check-executables-changed + run: nix develop -c ./ci/benchmarks/bench-runner/target/release/bench-runner --check-executables-changed From 64ae063022a2c204e028ab38d16dedbc38a98201 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 25 Oct 2022 18:08:14 +0200 Subject: [PATCH 5/6] strip debug before sha --- .github/workflows/benchmarks.yml | 6 +-- Cargo.toml | 2 +- ci/benchmarks/bench-runner/src/main.rs | 29 ++++++++++--- crates/cli_utils/src/bench_utils.rs | 2 +- crates/compiler/build/src/link.rs | 56 +++++++++++--------------- 5 files changed, 50 insertions(+), 45 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 68d234722e..ed1ac23bf6 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -33,12 +33,8 @@ jobs: - name: on current branch; prepare a self-contained benchmark folder run: nix develop -c ./ci/benchmarks/prep_folder.sh branch - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: build benchmark runner - run: nix develop -c `cd ci/benchmarks/bench-runner && cargo build --release && cd ../../..` + run: nix develop -c bash -c "cd ci/benchmarks/bench-runner && cargo build --release && cd ../../.." - name: run benchmarks with regression check run: nix develop -c ./ci/benchmarks/bench-runner/target/release/bench-runner --check-executables-changed diff --git a/Cargo.toml b/Cargo.toml index 6a5e0b066c..4106ed25cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ members = [ "crates/wasi-libc-sys", ] exclude = [ - "ci/bench-runner", + "ci/benchmarks/bench-runner", # Examples sometimes have Rust hosts in their platforms. The compiler should ignore those. "crates/cli_testing_examples", "examples", diff --git a/ci/benchmarks/bench-runner/src/main.rs b/ci/benchmarks/bench-runner/src/main.rs index 38afcd801d..7fbbd91979 100644 --- a/ci/benchmarks/bench-runner/src/main.rs +++ b/ci/benchmarks/bench-runner/src/main.rs @@ -33,7 +33,7 @@ fn main() { if check_if_bench_executables_changed() { println!( - "Comparison of sha256 of executables reveals changes, doing full benchmarks..." + "\n\nComparison of sha256 of executables reveals changes, doing full benchmarks...\n\n" ); let all_regressed_benches = do_all_benches(optional_args.nr_repeat_benchmarks); @@ -85,6 +85,8 @@ fn do_all_benches(nr_repeat_benchmarks: usize) -> HashSet { return HashSet::new(); } + println!("\n\nDoing benchmarks {:?} times to reduce flukes.\n\n", nr_repeat_benchmarks); + for _ in 1..nr_repeat_benchmarks { delete_old_bench_results(); do_benchmark("main"); @@ -112,7 +114,7 @@ fn do_benchmark(branch_name: &'static str) -> HashSet { )) .args(&["--bench", "--noplot"]) .stdout(Stdio::piped()) - .stderr(Stdio::piped()) + .stderr(Stdio::inherit()) .spawn() .unwrap_or_else(|_| panic!("Failed to benchmark {}.", branch_name)); @@ -133,14 +135,14 @@ fn do_benchmark(branch_name: &'static str) -> HashSet { "Failed to get line that contains benchmark name from last_three_lines_queue.", ); - let regex_match = bench_name_regex.find(regressed_bench_name_line).expect("This line should hoave the benchmark name between double quotes but I could not match it"); + let regex_match = bench_name_regex.find(regressed_bench_name_line).expect("This line should have the benchmark name between double quotes but I could not match it"); regressed_benches.insert(regex_match.as_str().to_string().replace("\"", "")); } last_three_lines_queue.push_front(line_str.clone()); - println!("bench {:?}: {:?}", branch_name, line_str); + println!(">>bench {:?}: {:?}", branch_name, line_str); } regressed_benches @@ -186,8 +188,20 @@ fn sha256_digest(mut reader: R) -> Result { } fn sha_file(file_path: &Path) -> Result { - let input = File::open(file_path)?; - let reader = BufReader::new(input); + // Debug info is dependent on the dir in which executable was created, + // so we need to strip that to be able to compare binaries. + let no_debug_info_file_path = file_path.to_str().unwrap().to_string() + ("_no_debug_info"); + std::fs::copy(file_path, &no_debug_info_file_path)?; + + let strip_output = Command::new("strip") + .args(["--strip-debug", &no_debug_info_file_path]) + .output() + .expect("failed to execute process"); + + assert!(strip_output.status.success()); + + let no_debug_info_file = File::open(no_debug_info_file_path)?; + let reader = BufReader::new(no_debug_info_file); let digest = sha256_digest(reader)?; Ok(HEXUPPER.encode(digest.as_ref())) @@ -241,6 +255,9 @@ fn check_if_bench_executables_changed() -> bool { if let Some(main_hash_val) = main_bench_hashes.get(key) { if let Some(branch_hash_val) = branch_bench_hashes.get(key) { if !main_hash_val.eq(branch_hash_val) { + dbg!(main_hash_val); + dbg!(branch_hash_val); + dbg!(key); return true; } } else { diff --git a/crates/cli_utils/src/bench_utils.rs b/crates/cli_utils/src/bench_utils.rs index 31da15a8e7..a49161b78b 100644 --- a/crates/cli_utils/src/bench_utils.rs +++ b/crates/cli_utils/src/bench_utils.rs @@ -2,7 +2,7 @@ use crate::helpers::{file_path_from_root, run_cmd, run_roc}; use criterion::{black_box, measurement::Measurement, BenchmarkGroup}; use std::{path::Path, thread}; -const CFOLD_STACK_SIZE: usize = 8192 * 100000; +const CFOLD_STACK_SIZE: usize = 16384 * 100000; const OPTIMIZE_FLAG: &str = "--optimize"; diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 601a21bd56..48c40a29a6 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -143,7 +143,7 @@ pub fn build_zig_host_native( command.args(&[ zig_host_src, - emit_bin, + &format!("-femit-bin={}", emit_bin), "--pkg-begin", "str", zig_str_path, @@ -211,7 +211,7 @@ pub fn build_zig_host_native( command.args(&[ zig_host_src, - emit_bin, + &format!("-femit-bin={}", emit_bin), "--pkg-begin", "str", zig_str_path, @@ -308,7 +308,7 @@ pub fn build_zig_host_native( } command.args(&[ zig_host_src, - emit_bin, + &format!("-femit-bin={}", emit_bin), "--pkg-begin", "str", zig_str_path, @@ -583,8 +583,6 @@ pub fn rebuild_host( ) } Architecture::X86_64 => { - let emit_bin = format!("-femit-bin={}", host_dest.to_str().unwrap()); - let target = match target.operating_system { OperatingSystem::Windows => "x86_64-windows-gnu", _ => "native", @@ -593,7 +591,7 @@ pub fn rebuild_host( build_zig_host_native( &env_path, &env_home, - &emit_bin, + host_dest.to_str().unwrap(), zig_host_src.to_str().unwrap(), zig_str_path.to_str().unwrap(), target, @@ -601,33 +599,27 @@ pub fn rebuild_host( shared_lib_path, ) } - Architecture::X86_32(_) => { - let emit_bin = format!("-femit-bin={}", host_dest.to_str().unwrap()); - build_zig_host_native( - &env_path, - &env_home, - &emit_bin, - zig_host_src.to_str().unwrap(), - zig_str_path.to_str().unwrap(), - "i386-linux-musl", - opt_level, - shared_lib_path, - ) - } + Architecture::X86_32(_) => build_zig_host_native( + &env_path, + &env_home, + host_dest.to_str().unwrap(), + zig_host_src.to_str().unwrap(), + zig_str_path.to_str().unwrap(), + "i386-linux-musl", + opt_level, + shared_lib_path, + ), - Architecture::Aarch64(_) => { - let emit_bin = format!("-femit-bin={}", host_dest.to_str().unwrap()); - build_zig_host_native( - &env_path, - &env_home, - &emit_bin, - zig_host_src.to_str().unwrap(), - zig_str_path.to_str().unwrap(), - target_zig_str(target), - opt_level, - shared_lib_path, - ) - } + Architecture::Aarch64(_) => build_zig_host_native( + &env_path, + &env_home, + host_dest.to_str().unwrap(), + zig_host_src.to_str().unwrap(), + zig_str_path.to_str().unwrap(), + target_zig_str(target), + opt_level, + shared_lib_path, + ), _ => internal_error!("Unsupported architecture {:?}", target.architecture), }; From 5ea5d9830ed69dded0003790f693cc3ab1bf0a4d Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 25 Oct 2022 20:09:42 +0200 Subject: [PATCH 6/6] minor cleanup --- ci/benchmarks/bench-runner/src/main.rs | 3 --- crates/cli_utils/src/bench_utils.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ci/benchmarks/bench-runner/src/main.rs b/ci/benchmarks/bench-runner/src/main.rs index 7fbbd91979..86bd30d82c 100644 --- a/ci/benchmarks/bench-runner/src/main.rs +++ b/ci/benchmarks/bench-runner/src/main.rs @@ -255,9 +255,6 @@ fn check_if_bench_executables_changed() -> bool { if let Some(main_hash_val) = main_bench_hashes.get(key) { if let Some(branch_hash_val) = branch_bench_hashes.get(key) { if !main_hash_val.eq(branch_hash_val) { - dbg!(main_hash_val); - dbg!(branch_hash_val); - dbg!(key); return true; } } else { diff --git a/crates/cli_utils/src/bench_utils.rs b/crates/cli_utils/src/bench_utils.rs index a49161b78b..31da15a8e7 100644 --- a/crates/cli_utils/src/bench_utils.rs +++ b/crates/cli_utils/src/bench_utils.rs @@ -2,7 +2,7 @@ use crate::helpers::{file_path_from_root, run_cmd, run_roc}; use criterion::{black_box, measurement::Measurement, BenchmarkGroup}; use std::{path::Path, thread}; -const CFOLD_STACK_SIZE: usize = 16384 * 100000; +const CFOLD_STACK_SIZE: usize = 8192 * 100000; const OPTIMIZE_FLAG: &str = "--optimize";