Skip to content

std::max(..., kMaxLength leads to massive GC pressure #72

@blattersturm

Description

@blattersturm

Ever since Node.js 14 support got added to this library, and when run under Node.js 14+, we're having very slow performance when using this module.

Investigation showed that every external node::Buffer allocation would lead to a GC, and indeed, a lot of allocations make a buffer of 0x3fffffff in length leading to the external memory country in V8 getting angry.

Looking a bit further, we find this bit of code:

length = std::max<size_t>(length, kMaxLength);

... which uses std::max to make every allocation the maximum length, which in this case is 0x3fffffff.

Sadly, changing this to std::min makes for a lot of intermittent failures of the Check failed: result.second. kind returning when run repeatedly. I guess the initial Node.js 14+ support never worked correctly and relied on this broken behavior.

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