Skip to content
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

First eyre::Result::Err variant is slow to construct if backtraces are enabled #148

Open
deifactor opened this issue Dec 28, 2023 · 0 comments

Comments

@deifactor
Copy link

With color-eyre 0.6.2 and RUST_BACKTRACE=1

fn main() -> Result<()> {
    color_eyre::install()?;
    let now = Instant::now();
    let _ = eyre::eyre!("one");
    println!("first error: {:?}", Instant::now() - now);
    let now = Instant::now();
    let _ = eyre::eyre!("two");
    println!("second error: {:?}", Instant::now() - now);
    Ok(())
}

cargo run --release gives

first error: 6.476077ms
second error: 35.841µs

Getting rid of the color_eyre::install() call or not setting RUST_BACKTRACE gets rid of this behavior. This bit me because I'm writing a music player and the decoder library I'm using signals EOF by constructing an Err, so I wind up underflowing my buffer on the first EOF I got. I can work around this by just constructing and throwing away an err variant; if this isn't fixable, IMO it should be documented.

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

No branches or pull requests

1 participant