Sitelet https://github.com/nodejs/node/issues/43810
Skip to content

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

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.

Activity

  1. kvakil commented on Jul 13, 2022

    @kvakil
    ContributorAuthor

    (If it's not obvious from the issue description; I'm happy to make a PR with an implementation & tests if such a patch would be welcome.)

  2. added
    workerIssues and PRs related to the worker_threads module and Worker API.
    on Jul 13, 2022
  3. bnoordhuis commented on Jul 14, 2022

    @bnoordhuis
    Member

    Sounds reasonable to me, go for it.

    An alternative approach would be to scan the command line for flags and when they're present make node print the relevant information (thread id?)

    Neither approach seems strictly superior, so 🤷

  4. moved this to Pending Triage in Node.js feature requestson Oct 22, 2022
  5. github-actions commented on Jan 11, 2023

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  6. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jan 11, 2023
  7. github-actions commented on Feb 10, 2023

    @github-actions
    Contributor

    There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  8. moved this from Pending Triage to Stale in Node.js feature requestson Apr 4, 2023
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

    feature requestIssues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.workerIssues and PRs related to the worker_threads module and Worker API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions