From 41ddefcdc9e16ec3f2618844855f5bffe2582568 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 15 Dec 2025 16:54:28 +0800 Subject: [PATCH 1/4] fix(test): speed up debug and codecov tests --- .github/workflows/coverage.yml | 10 +++------- Cargo.toml | 4 +++- Makefile | 3 +++ interop-tests/Cargo.toml | 16 ++++++++++++++++ src/tool/subcommands/api_cmd/test_snapshot.rs | 5 ----- src/utils/mod.rs | 2 ++ 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index af5cfa2c1e9a..b7f807ac2577 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,6 +31,8 @@ env: RUSTC_WRAPPER: sccache CC: sccache clang CXX: sccache clang++ + # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times + RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" jobs: codecov: @@ -50,13 +52,7 @@ jobs: - uses: taiki-e/install-action@cargo-llvm-cov - uses: taiki-e/install-action@nextest - name: Generate code coverage - run: | - cargo llvm-cov --workspace --codecov --output-path lcov.info nextest - env: - CC: "sccache clang" - CXX: "sccache clang++" - # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times - RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" + run: make codecov # Save lcov.info as an artifact for debugging purposes - uses: actions/upload-artifact@v4 with: diff --git a/Cargo.toml b/Cargo.toml index f9d09ee32c50..d08d4d3a4f0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -268,9 +268,11 @@ rust2go = { workspace = true, features = ["build"] } debug = "line-tables-only" split-debuginfo = "unpacked" -# Avoid generating any debug information for dependencies [profile.dev.package."*"] +# Avoid generating any debug information for dependencies debug = false +# Speed up debug tests and codecov tests +opt-level = 1 # Profile for interactive debugging sessions, e.g., with LLDB. # Doesn't work with Go FFI - disable it with `FOREST_F3_SIDECAR_FFI_BUILD_OPT_OUT=1`. diff --git a/Makefile b/Makefile index 1bcba1f4610c..35beaf3e627c 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,9 @@ test-release: test-all: test test-release +codecov: + cargo llvm-cov --workspace --codecov --output-path lcov.info --ignore-run-fail + # Checks if all headers are present and adds if not license: ./scripts/add_license.sh diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index c07527cc8277..83789cc4f781 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -41,3 +41,19 @@ tokio = { workspace = true, features = ['full'] } [build-dependencies] rust2go = { workspace = true, features = ["build"] } + +# https://doc.rust-lang.org/stable/cargo/guide/build-performance.html#reduce-amount-of-generated-debug-information +[profile.dev] +debug = "line-tables-only" +split-debuginfo = "unpacked" + +[profile.dev.package."*"] +# Avoid generating any debug information for dependencies +debug = false +# Speed up debug tests and codecov tests +opt-level = 1 + +[profile.dev.package."forest-filecoin"] +debug = "line-tables-only" +split-debuginfo = "unpacked" +opt-level = 0 diff --git a/src/tool/subcommands/api_cmd/test_snapshot.rs b/src/tool/subcommands/api_cmd/test_snapshot.rs index b47bb6448613..55d50e79ac2a 100644 --- a/src/tool/subcommands/api_cmd/test_snapshot.rs +++ b/src/tool/subcommands/api_cmd/test_snapshot.rs @@ -199,11 +199,6 @@ mod tests { include!(concat!(env!("OUT_DIR"), "/__rpc_regression_tests_gen.rs")); async fn rpc_regression_test_run(name: &str) { - // Skip for debug build on CI as the downloading is slow and flaky - if crate::utils::is_ci() && crate::utils::is_debug_build() { - return; - } - // Set proof parameter data dir and make sure the proofs are available { static PROOF_PARAMS_LOCK: LazyLock> = LazyLock::new(|| Mutex::new(())); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7b5653328e3e..49de3de44285 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -169,11 +169,13 @@ pub enum RetryError { RetriesExceeded, } +#[allow(dead_code)] #[cfg(test)] pub fn is_debug_build() -> bool { cfg!(debug_assertions) } +#[allow(dead_code)] #[cfg(test)] pub fn is_ci() -> bool { // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables From 03e4b94ce774bc783f65ff59e32a270f71e81371 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 15 Dec 2025 19:06:27 +0800 Subject: [PATCH 2/4] fix(ci): deprecate quick cargo profile --- .github/workflows/butterflynet.yml | 2 +- .github/workflows/forest.yml | 2 +- Cargo.toml | 5 ----- Makefile | 11 +---------- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/.github/workflows/butterflynet.yml b/.github/workflows/butterflynet.yml index 9b7b5f4c6487..7451b677d27c 100644 --- a/.github/workflows/butterflynet.yml +++ b/.github/workflows/butterflynet.yml @@ -31,7 +31,7 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - run: make install-slim-quick + run: make install-slim - name: Run butterflynet checks run: ./scripts/tests/butterflynet_check.sh timeout-minutes: ${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }} diff --git a/.github/workflows/forest.yml b/.github/workflows/forest.yml index 3cfe9e96755b..9c195b27cc08 100644 --- a/.github/workflows/forest.yml +++ b/.github/workflows/forest.yml @@ -92,7 +92,7 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - run: make install-slim-quick + run: make install-slim - uses: actions/upload-artifact@v5 with: name: "forest-${{ runner.os }}" diff --git a/Cargo.toml b/Cargo.toml index d08d4d3a4f0e..19701cc24d25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -282,11 +282,6 @@ debug = "full" # This works on Linux. On other platforms, refer to https://doc.rust-lang.org/rustc/codegen-options/index.html#split-debuginfo split-debuginfo = "off" -[profile.quick] -inherits = "release" -opt-level = 1 -lto = "off" - [profile.profiling] inherits = "dev" opt-level = 0 diff --git a/Makefile b/Makefile index 35beaf3e627c..2fe1bfba19b6 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,15 @@ install: cargo install --locked --path . --force -install-quick: - cargo install --profile quick --locked --path . --force - install-slim: cargo install --no-default-features --features slim --locked --path . --force -install-slim-quick: - cargo install --profile quick --no-default-features --features slim --locked --path . --force - install-minimum: cargo install --no-default-features --locked --path . --force install-lto-fat: cargo install --locked --force --profile release-lto-fat --path . -install-minimum-quick: - cargo install --profile quick --no-default-features --locked --path . --force - # Installs Forest binaries with default rust global allocator install-with-rustalloc: cargo install --locked --path . --force --no-default-features --features rustalloc @@ -106,7 +97,7 @@ test: cargo test --doc --features doctest-private test-release: - cargo nextest run --cargo-profile quick --workspace --no-fail-fast + cargo nextest run --cargo-profile release --workspace --no-fail-fast test-all: test test-release From 3f42d9845ca1ed7a7461390199e880dea73f8508 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Wed, 17 Dec 2025 00:39:58 +0800 Subject: [PATCH 3/4] fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2fe1bfba19b6..20144ab1990a 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ test: cargo test --doc --features doctest-private test-release: - cargo nextest run --cargo-profile release --workspace --no-fail-fast + cargo nextest run --release --workspace --no-fail-fast test-all: test test-release From 7029e2e6e212b8c8b32f20d06a9020b7bf740c4f Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Sat, 20 Dec 2025 00:31:05 +0800 Subject: [PATCH 4/4] fix --- .github/workflows/butterflynet.yml | 2 +- .github/workflows/forest.yml | 2 +- Cargo.toml | 2 -- Makefile | 9 ++++----- interop-tests/Cargo.toml | 1 - src/cli_shared/mod.rs | 3 +-- src/lib.rs | 3 +-- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/butterflynet.yml b/.github/workflows/butterflynet.yml index 7451b677d27c..a9570ed96381 100644 --- a/.github/workflows/butterflynet.yml +++ b/.github/workflows/butterflynet.yml @@ -31,7 +31,7 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - run: make install-slim + run: make install-minimum-quick - name: Run butterflynet checks run: ./scripts/tests/butterflynet_check.sh timeout-minutes: ${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }} diff --git a/.github/workflows/forest.yml b/.github/workflows/forest.yml index 837a0b56db6f..563c2d483510 100644 --- a/.github/workflows/forest.yml +++ b/.github/workflows/forest.yml @@ -92,7 +92,7 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - run: make install-slim + run: make install-minimum-quick - uses: actions/upload-artifact@v6 with: name: "forest-${{ runner.os }}" diff --git a/Cargo.toml b/Cargo.toml index 77f7381b2025..498f94cb3cc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -303,13 +303,11 @@ lto = "fat" # These should be refactored (probably removed) in #2984 [features] default = ["jemalloc", "tokio-console", "tracing-loki", "tracing-chrome"] -slim = ["rustalloc"] doctest-private = [] # see lib.rs::doctest_private benchmark-private = ["dep:criterion"] # see lib.rs::benchmark_private interop-tests-private = [] # see lib.rs::interop_tests_private # Allocator. Use at most one of these. -rustalloc = [] jemalloc = ["dep:tikv-jemallocator"] system-alloc = [] # Use the platform allocator (for memory profiling). diff --git a/Makefile b/Makefile index 3c639d619e04..c0214aa63769 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ install: cargo install --locked --path . --force -install-slim: - cargo install --no-default-features --features slim --locked --path . --force - install-minimum: cargo install --no-default-features --locked --path . --force +install-minimum-quick: + cargo install --debug --no-default-features --locked --path . --force + install-lto-fat: cargo install --locked --force --profile release-lto-fat --path . # Installs Forest binaries with default rust global allocator install-with-rustalloc: - cargo install --locked --path . --force --no-default-features --features rustalloc + cargo install --locked --path . --force --no-default-features install-lint-tools: cargo install --locked taplo-cli @@ -58,7 +58,6 @@ lint: license clean lint-clippy # --quiet: don't show build logs lint-clippy: cargo clippy --all-targets --quiet --no-deps -- --deny=warnings - cargo clippy --all-targets --no-default-features --features slim --quiet --no-deps -- --deny=warnings cargo clippy --all-targets --no-default-features --quiet --no-deps -- --deny=warnings cargo clippy --benches --features benchmark-private --quiet --no-deps -- --deny=warnings # check docs.rs build diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 83789cc4f781..de44ce5ef1b1 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -15,7 +15,6 @@ anyhow = { workspace = true } cid = { workspace = true } flume = { workspace = true } forest = { package = "forest-filecoin", path = "../", default-features = false, features = [ - "rustalloc", "interop-tests-private", "no-f3-sidecar", ] } diff --git a/src/cli_shared/mod.rs b/src/cli_shared/mod.rs index eec4bf91bbd5..7d57a26f201c 100644 --- a/src/cli_shared/mod.rs +++ b/src/cli_shared/mod.rs @@ -10,8 +10,7 @@ use crate::utils::io::read_toml; use std::path::PathBuf; cfg_if::cfg_if! { - if #[cfg(feature = "rustalloc")] { - } else if #[cfg(feature = "jemalloc")] { + if #[cfg(feature = "jemalloc")] { pub use tikv_jemallocator; } } diff --git a/src/lib.rs b/src/lib.rs index 17c035c8fdf3..5f7c589a2040 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,8 +25,7 @@ )] cfg_if::cfg_if! { - if #[cfg(feature = "rustalloc")] { - } else if #[cfg(feature = "jemalloc")] { + if #[cfg(feature = "jemalloc")] { use crate::cli_shared::tikv_jemallocator::Jemalloc; #[global_allocator] static GLOBAL: Jemalloc = Jemalloc;