Skip to content

[parity] node:perf_hooks timerify — async settlement, construct, entry arguments, and name/length descriptors #8234

Description

@proggeramlug

Split out of #6766 after PR #8229, which made timerify's histogram option real (timerify(fn, { histogram }) now validates the handle and records durations) but left five behaviours unimplemented. All five live in perf_timerify_wrapper / js_perf_timerify in crates/perry-runtime/src/perf_hooks.rs.

Reproduce with ./run_parity_tests.sh --suite node-suite --module perf_hooks.

1. Async settlement — the wrapper records at return, not at settle (2 cases)

Node defers the measurement until the returned promise settles. Perry records synchronously, so an async function's entry/sample lands one turn early.

timerify/async-fulfill:

node:   pending records: 0 / result: 5 / settled records: 1
perry:  pending records: 1 / result: 5 / settled records: 0

timerify/histogram-async:

node:   pending: 0 / result: 6 / settled: 1 / positive: true
perry:  pending: 1

Needs the wrapper to detect a thenable result and attach a native continuation that emits the entry (and records into the optional histogram) on settlement.

2. new through the wrapper (timerify/constructor)

class Value { marker = 1 }
const Wrapped = timerify(Value);
new Wrapped()          // node: a Value instance, marker 1;  perry: instance false, marker undefined
Wrapped()              // node: TypeError (class called without new);  perry: "call ok"

3. Entry arguments (timerify/entry-arguments)

Node's function entry carries the call arguments both as entry.detail (an array) and as indexed properties on the entry itself:

`${entry.detail.length}:${entry.detail[0]}:${entry.detail[1] === argument}:${entry[0]}:${entry[1] === argument}`
node:   arguments: 2:1:true:1:true
perry:  TypeError: Cannot read properties of null (reading 'length')   (detail is null)

4. name/length descriptor flags (timerify/name-length-descriptors)

The values are already right; the attributes are not. Node defines both as enumerable and non-configurable on the wrapper:

node:   name timerified sample false true false     (value, writable, enumerable, configurable)
        length 2 false true false
perry:  name timerified sample false false true
        length 2 false false true

This one needs per-property descriptor attributes on a closure, so it may be blocked on the same machinery as #8231.

Metadata

Metadata

Assignees

No one assigned

    Labels

    parityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions