Skip to content

proposal: add num cpu cores to process.report output #307

Closed

Description

@boneskull

In the report generated by process.report, we have resourceUsage.cpuConsumptionPercent.

As per the original PR, this is the percentage of CPU in use across all cpu cores. The issue I'm raising here didn't seem to be considered--rather the maintainer decided that granular information about each core was not useful (and they are right).

Now, it's been awhile since my computer architecture classes, but what I think this means is that you cannot just look at the number reported and know what it means. A usage of 100% on system A may be a problem, but a usage of 120% on system B might not be.

(We are not guaranteed to be consuming the report on the machine it was generated on, either.)

So, I propose adding header.osCpus, which would be a number corresponding to the output of os.cpus().length. A consumer can then use both of these to determine the theoretical ceiling of the CPU consumption percentage value (multiply header.osCpus by 100).

If it's a good idea, I could implement. If I can do it in lib/internal/process/report.js that'd be even better. 😝

Activity

  1. sam-github commented on Jun 10, 2019

    @sam-github

    Seems pretty reasonable to me, @richardlau, thoughts?

  2. richardlau commented on Jun 10, 2019

    @richardlau
    Member

    Yes, sounds reasonable. One question is whether it would be useful to include more information about the CPU's in the report, e.g. the information returned by uv_cpu_info() (i.e. the contents of the returned uv_cpu_info_t's)?

    The report is written out in C++ code -- for the header section see: https://github.com/nodejs/node/blob/04633eeeb93c5a86a6635940eb4f34a7839ada11/src/node_report.cc#L150-L236

  3. boneskull commented on Jun 11, 2019

    @boneskull
    MemberAuthor

    @richardlau Isn't the cpu time information in the uv_cpu_info_t put into resourceUsage.userCpuSeconds & resourceUsage.kernelCpuSeconds? So it'd be essentially duplicate information?

    At any rate, I don't have a use for anything past the number of cores, and could only speculate on what someone would want to do with the extra info here.

  4. richardlau commented on Jun 11, 2019

    @richardlau
    Member

    resourceUsage is obtained from uv_getrusage(): https://github.com/nodejs/node/blob/155caf72bd7972aa46a7b4e8210d13150f8feb43/src/node_report.cc#L423-L452
    It may well be that the information is duplicated in the two calls.

    The only reason I'm speculating on whether it's worth including the extra information is in terms of the report format (i.e. we could go the simple route and have header.osCpus as the count but then if we wanted to expand the information that would potentially be a format change).

  5. mhdawson commented on Jun 11, 2019

    @mhdawson
    Member

    +1 on adding the number of cores to the report.

  6. added a commit that references this issue on Jun 16, 2019
  7. added a commit that references this issue on Jun 17, 2019
  8. added a commit that references this issue on Jun 18, 2019
  9. mmarchini commented on Jul 8, 2019

    @mmarchini
    Contributor

    @boneskull nodejs/node#28188 landed, so the number of CPUs can be determined by the number of entries in osCpus. Can we close this issue?

  10. boneskull commented on Jul 8, 2019

    @boneskull
    MemberAuthor

    yep!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions