Skip to content

High CPU usage when attach_stacktrace=true #597

Open
@agrinman

Description

@agrinman

Environment

actix-web

What version are you running? Etc.
0.31.5

Steps to Reproduce

When setting up sentry to attach stack traces, as below:

    let _guard: sentry::ClientInitGuard = sentry::init((
        config.sentry_url.as_str(),
        sentry::ClientOptions {
            release: sentry::release_name!(),
            environment: Some(Cow::Owned(config.service_config.environment.clone())),
            sample_rate,
            attach_stacktrace: true, // <---- this right here
            ..Default::default()
        },
    ));

We see a really high CPU usage (up to ~800% on my dev linux machine with 16 cores) when using a load test tool like vegeta:

For example,

echo "GET http://localhost:8000/just_return_an_error" | vegeta attack -duration=10s -rate=2000/1s -timeout=30s | tee results.bin | vegeta report

A bunch of requests actually don't even complete (timeout) because the CPU usage spikes so high. This all goes away when making attach_stacktrace = false.

It's important to note that we have a large enum error return type, but it's been boxed:

struct Error(Box<ErrorInner>);

enum ErrorInner {
	Many,
	Different,
	Variants(WithMaybeLargeProperties),
	//..
}

Any idea what's going on here or how we can still get stack traces?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions