Skip to content

Provide a way to expose VM's cpu/memory usage #12940

@matteofigus

Description

@matteofigus

It would be useful for some work I'm doing to be able to inspect cpu and memory usage for a vm script execution. A common use case may be using vm for micro-benchmarking code and spot leaks during testing.

An example could be:

const script = vm.runInNewContext('count += 1; name = "kitty"', sandbox);
script.memoryUsage(); // => similar to process.memoryUsage()
script.cpuUsage(); // => similar to process.cpuUsage()

My questions are:

  1. Is it possible?
  2. If yes, how would be the best way? Could it be an extension to the current vm's node api (as suggested by the example)?
  3. If yes, a PR would be considered?
  4. If yes, would I be able to help with that? I am not familiar with the node code (especially the v8 part) but if we would agree about having this feature and its feasibility, I think I would be happy to help if needed, perhaps with some mentoring and/or guidance.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions