Skip to content

Make SetCaptureStackTraceForUncaughtExceptions configurable for a 26% speed boost #5332

@mhart

Description

@mhart

This line will always execute in workerd (because errorReporter != kj::none)

if (isolate->impl->inspector != kj::none || errorReporter != kj::none) {
lock.v8Isolate->SetCaptureStackTraceForUncaughtExceptions(true);
}

This has an effect even when running normally without an inspector attached, and even when the thrown objects are caught (So the "ForUncaughtExceptions" bit is apparently not true – will investigate this in the v8 codebase)

For certain Next.js streaming rendering workloads this can have quite an impact because React uses throw for flow control (I know, let's not go there).

By removing this line I see a 26% improvement in performance – again, just when running normally, no inspector attached.

If we want to keep the logic as is (Do we? Or should we drop the errorReporter != kj::none bit and only have this execute when we're attached to an inspector?) – then I propose that we make it configurable, so that people running workerd in production, or when benchmarking, are not hindered by this behaviour. Basically I just want an option to not execute this line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions