Skip to content

Criterion benchmarks hang with target-cpu=znver1 #65618

Closed
@novacrazy

Description

@novacrazy

On my system, a Zen 1 AMD CPU, attempting to run Criterion benchmarks with RUSTFLAGS = "-C target-cpu=znver1" results in the benchmark hanging at the Analyzing stage for a few minutes before I killed the program.

Without the flags, it doesn't hang at all, as expected.

This affects stable, beta and nightly, and is probably related to LLVM 9.

Code that can hang on stable:

#[macro_use]
extern crate criterion;

use criterion::{Criterion, ParameterizedBenchmark};

fn criterion_benchmark(c: &mut Criterion) {
    c.bench(
        "bench",
        ParameterizedBenchmark::new(
            "old",
            |b, _| {
                b.iter(|| {});
            },
            vec![()],
        )
        .with_function("new", |b, _| {
            b.iter(|| {});
        }),
    );
}

criterion_group!(my_benches, criterion_benchmark);
criterion_main!(my_benches);

using cargo +stable bench

No special flags are present in the Cargo.toml

[package]
name = "bench-test"
version = "0.1.0"
authors = ["novacrazy <[email protected]>"]
edition = "2018"

[dev-dependencies]
criterion = "0.3.0"

[[bench]]
name = "benchmark_name"
harness = false

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-windows-msvcToolchain: MSVC, Operating system: WindowsO-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions