Skip to content

JSON.stringify is too slow then nodejs #6009

Description

@zaaack

What happened

JSON.stringify on a small nested object (100 iterations) took 3388ms in compiled Perry binary, vs 32ms in native Node.js — a 100x regression.

All other runners (tsx, tsx-transpiled node) cluster within 30–38ms.

What you expected

A native binary should match or beat V8 JIT on JSON.stringify, not be 100x slower.

Minimal reproduction

const obj = { a: 1, b: 'foo', c: [1, 2, 3], d: { x: true } };

// Run 100 times
for (let i = 0; i < 100; i++) JSON.stringify(obj);

Command you ran:

perry compile benchmark.ts -o dist/benchmark-perry
./dist/benchmark-perry

Environment

  • Perry version: 0.5.1220
  • Host OS: linux
  • Target: native
  • Installed via: (from path /usr/local/bin/perry)

Diagnostic output

[json-stringify-100] 3388ms | rss=1396MB | heap=287MB

For comparison, same workload via Node.js:

[json-stringify-100] 32ms | rss=257MB | heap=33MB

Anything else

The object is static and trivially small (4 keys, shallow nesting). The problem compounds — RSS grows to 1.4GB and heapUsed to 287MB by the end of the benchmark suite, suggesting the serializer may be allocating without releasing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions