Rust Benchmark Error

Hello everyone,
I encountered an error while benchmarking 'vec' and 'vec_deque' in Rust. I attempted to use 'vec_deque.rs' and 'vec.rs' from 'rust/library/alloc/benches' and added the following code to my 'Cargo.toml' file.


[[bench]]
name = "vec_deque_bench"
path = "benches/vec_deque.rs"
harness = false

[[bench]]
name = "vec_bench"
path = "benches/vec.rs"
harness = false


I then tried to run the benchmarks with the following commands:
cargo bench --bench vec_bench
cargo bench --bench vec_deque_bench

Unfortunately, the benchmarks failed, and I received a lengthy error message. After investigating, I concluded that I cannot directly modify the user code.

I will attach part of the error for reference.

  • In response to the suggestion that the version might be the issue, I've updated Rust, and my current version is rustc 1.74.0-nightly (9f5fc1bd4 2023-09-02).

How can I resolve this issue? Or are there any alternative benchmarking methods available?

These implementations depend on compiler-private features, and are expected to be compiled together with the rustc compiler.

You could use regular Vec and VecDeque from std that ships with the compiler, instead of compiling them from source. Otherwise you'll have to edit the sources to remove dependencies on compiler-private features like lang_item. These files aren't written in standard Rust.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.