Skip to content

Optimize config resolution for non-matching targets in --exact runs#4296

Open
franciszekjob wants to merge 18 commits intomasterfrom
franciszekjob/3899-optimize-configs-resolution-with-exact-flag
Open

Optimize config resolution for non-matching targets in --exact runs#4296
franciszekjob wants to merge 18 commits intomasterfrom
franciszekjob/3899-optimize-configs-resolution-with-exact-flag

Conversation

@franciszekjob
Copy link
Copy Markdown
Contributor

@franciszekjob franciszekjob commented Apr 21, 2026

Towards #3899

Introduced changes

Skip config resolution for non-matching targets when --exact flag is used. This change is helpful for test run code lens in LS, since they use --exact.


With --workspace flag

Before

➜  cairo-contracts git:(main) ✗ hyperfine --runs 5 "snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --workspace"                 
Benchmark 1: snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --workspace
  Time (mean ± σ):     38.935 s ±  7.293 s    [User: 97.577 s, System: 19.230 s]
  Range (min … max):   30.666 s … 48.018 s    5 runs

After

➜  cairo-contracts git:(main) ✗ hyperfine --runs 5 "/Users/franciszekjob/Projects/SWM/starknet-foundry/target/release/snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --workspace"                 
Benchmark 1: /Users/franciszekjob/Projects/SWM/starknet-foundry/target/release/snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --workspace
  Time (mean ± σ):     29.249 s ±  2.614 s    [User: 22.787 s, System: 14.182 s]
  Range (min … max):   25.940 s … 32.706 s    5 runs

With --package flag

Before

➜  cairo-contracts git:(main) ✗ hyperfine --runs 5 "snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --package openzeppelin_token" 
Benchmark 1: snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --package openzeppelin_token
  Time (mean ± σ):     16.125 s ±  1.337 s    [User: 38.437 s, System: 6.164 s]
  Range (min … max):   14.457 s … 17.824 s    5 runs

After

➜  cairo-contracts git:(main) ✗ hyperfine --runs 5 "/Users/franciszekjob/Projects/SWM/starknet-foundry/target/release/snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --package openzeppelin_token"
Benchmark 1: /Users/franciszekjob/Projects/SWM/starknet-foundry/target/release/snforge test openzeppelin_token::tests::erc721::test_erc721::test_transfer_from_nonexistent --exact --package openzeppelin_token
  Time (mean ± σ):     11.330 s ±  1.318 s    [User: 7.184 s, System: 4.180 s]
  Range (min … max):    9.696 s … 13.110 s    5 runs

(Benches done in comparison with snforge nightly-2026-04-22)

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

Comment on lines -41 to -44
let casm_program = Arc::new(compile_raw_sierra_at_path(
test_target_raw.sierra_program_path.as_std_path(),
)?);

Copy link
Copy Markdown
Contributor Author

@franciszekjob franciszekjob Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Compilation was moved below so it happens only if there are tests to be run from a test target.

@franciszekjob franciszekjob changed the title Skip config resolution for non-matching targets in --exact runs Optimize config resolution for non-matching targets in --exact runs Apr 22, 2026
@franciszekjob franciszekjob marked this pull request as ready for review April 22, 2026 15:56
@franciszekjob franciszekjob requested a review from a team as a code owner April 22, 2026 15:56
Comment on lines +23 to +27
#[derive(Debug, Clone, Copy)]
pub enum TestNameSelection<'a> {
All,
ExactMatch(&'a str),
}
Copy link
Copy Markdown
Contributor Author

@franciszekjob franciszekjob Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: We can extend it later so the optimization will work with test name filter too. However, this will be related with the number of filtered out tests, which is displayed. For --exact we simply display other filtered out while for matching name filter, we actually count them.

Comment thread crates/forge-runner/src/running/target.rs Outdated
Comment thread crates/forge-runner/src/running/target.rs
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