Skip to content

cargo bench fails when running unittests #14247

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

Closed
abrassel opened this issue Jul 13, 2024 · 7 comments
Closed

cargo bench fails when running unittests #14247

abrassel opened this issue Jul 13, 2024 · 7 comments
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@abrassel
Copy link

abrassel commented Jul 13, 2024

Problem

I have a benchmark set up in my cargo project. When I run cargo bench I expect for it to execute this benchmark.

Instead, it begins executing my unit tests and then fails with a SIGKILL. However, running cargo test passes.

❯ cargo bench criterion_benchmark
   Compiling <> v1.7.0 (<>)
    Finished `bench` profile [optimized] target(s) in 3.19s
     Running unittests src/lib.rs (target/release/deps/<>_lib-799808ee04af93f2)
error: bench failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `<path/to/debug/target> criterion_benchmark --bench` (signal: 9, SIGKILL: kill)

Steps

  1. create cargo bench target. I used the fibonacci example from the Criterion quick start page.
  2. run cargo bench
  3. observe unit test failures.

Possible Solution(s)

I was curious if there might be an issue on my side so I checked out the Criterion repo. All tests and benchmarks work fine.

It seems as though something about the way my tests are executing does not play well with cargo bench.
I may be able to work around this by bypassing unittest execution, but even executing cargo bench -- <test_name> does not help.

Notes

No response

Version

cargo 1.80.0-nightly (4de0094ac 2024-05-09)
release: 1.80.0-nightly
commit-hash: 4de0094ac78743d2c8ff682489e35c8a7cafe8e4
commit-date: 2024-05-09
host: aarch64-apple-darwin
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0 (sys:0.4.72+curl-8.6.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.5.0 [64-bit]
@abrassel abrassel added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 13, 2024
@weihanglo
Copy link
Member

Just setup a new package and followed Getting Started. No issue found. Could you provide a complete minimal reproducer? Either a Git repo, or uploading a zip of your package.

@weihanglo
Copy link
Member

Saw SIGKILL so was wondering something like #13961 (comment). Looks like it only happens on this specific package but not other so may be irrelevant.

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Jul 13, 2024
@abrassel
Copy link
Author

I'll try to repro. My crate is proprietary so I'll have to make a repro. Can you give me more information about how I can debug this or what step of the build is failing?

@weihanglo
Copy link
Member

See #8961 and rust-lang/rust#79857. Check if it is OOM-killed.

@ehuss
Copy link
Contributor

ehuss commented Jul 13, 2024

On macOS, you can view the system logs to see if the memory_pressure system is activating, or any other unusual things. You can do that with the Console app (just click "start" to start recording), or in the CLI with the log show command. The log command has a bunch of options like --last 1m to just get the last minute, or filtering predicates.

@abrassel
Copy link
Author

Some updates. CARGO_BUILD_JOBS=1 cargo bench does not resolve the issue. @ehuss I ran Console with cargo bench and only saw this error: unable to get a dev_t for store 1795162192.

@abrassel
Copy link
Author

Root caused - my company laptop was blocking the executable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants