Skip to content

perf(compile): a flat ~4000-line exports table (mysql2's errors.js) hits the relocation-estimate cap and spends 138s in one LLVM unit #10663

Description

@proggeramlug

Found while measuring package compilability. Not a correctness bug — filing so the cost is recorded.

Compiling mysql2 from real source took 6m50s, dominated by a single module:
node_modules/mysql2/lib/constants/errors.js, a ~3973-line flat table of exports.X = N assignments.

It hit Perry's relocation-estimate cap (15,849 call sites against a 32M cap) and fell back to precise
shadow-frame codegen, which spent 138 seconds on that one LLVM unit alone.

A large flat constant-table module is a common shape in generated or protocol-constant files (error codes, opcode
tables, charset maps), so this is unlikely to be unique to mysql2. Worth checking whether the relocation estimate
is over-counting for a module that is almost entirely simple assignments with no real call graph — a flat
exports.X = <literal> table should be one of the cheapest things to compile, not the most expensive.

Context: this came out of a probe establishing which npm packages compile natively, as part of removing Perry's
hand-written Rust reimplementations in favour of the real packages. mysql2 compiles ✓ but fails at runtime for a
separate reason (#10661).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindingsperformanceRuntime, compile-time, build-size, or memory performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions