Skip to content

worker: add function to get address of current isolate #43810

@kvakil

Description

@kvakil

What is the problem this feature will solve?

When running NodeJS with --trace-gc (or --trace-gc-nvp /
--trace-gc-verbose), you get a line which looks like this:

[1847:0x5dad670]       41 ms: Scavenge 5.0 (5.4) -> 4.1 (5.7) MB, 1.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 

The first number 1847 is the PID of the NodeJS process, and the second hex
number 0x5dad670 is the address of the NodeJS isolate.

Unfortunately, when running with worker threads, multiple isolates exist, and
so it can be difficult to correlate application-level logging with the output
of --trace-gc.

What is the feature you are proposing to solve the problem?

Add a new function to worker_threads (or v8?) which returns the address of
the current NodeJS isolate as a string. This way application developers can
correlate structured log lines with these GC trace lines.

What alternatives have you considered?

Per #42346, trace-gc is a "Tier 1" tool, and this issue makes it
significantly less useful with worker threads. At $WORK we have a native
addon which does this currently, but I think it's not unreasonable for
this to be in core NodeJS?

Anyway, I defer to the wisdom of the crowds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.staleworkerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions