Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add loop idle time in diagnostic report #35940

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

gireeshpunathil
Copy link
Member

@gireeshpunathil gireeshpunathil commented Nov 3, 2020

Add libuv's cumulative idle time in the diagnostic report.
Modify the structure of libuv section to cater to this change

Refs: #34938

before

  "libuv": [
    {
      "type": "async",
      "is_active": true,
      "is_referenced": false,
      "address": "0x0000000105a0bd70"
    }
  ]

after

  "libuv": {
    "loop_idle_time": 22644.8,
    "handles": [
      {
      "type": "async",
      "is_active": true,
      "is_referenced": false,
      "address": "0x0000000105a0bd70"
      }
    ]
  }
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. report Issues and PRs related to process.report. labels Nov 3, 2020
@richardlau
Copy link
Member

Add libuv's cumulative idle time in the diagnostic report.
Modify the structure of libuv section to cater to this change

Refs: #34938

before

  "libuv": [
    {
      "type": "async",
      "is_active": true,
      "is_referenced": false,
      "address": "0x0000000105a0bd70"
    }
  ]

after

  "libuv": {
    "loop_idle_time": 22644.8,
    "handles": [
      {
      "type": "async",
      "is_active": true,
      "is_referenced": false,
      "address": "0x0000000105a0bd70"
      }
    ]
  }

Is this structural change (as opposed to just a new field) the sort of thing that should bump reportVersion?
cc @boneskull

@gireeshpunathil
Copy link
Member Author

@richardlau - it is a new field addition, but that led to a structural change too. Original structure libuv was an array as it contained homogeneous entries. But now with the idle time in it, it is no more uniform, so I converted it into an object. Happy to move it either side, upon review comments:

  • retain the libuv 's original structure and add the field elsewhere
  • modify the structure and bump the version

@cjihrig
Copy link
Contributor

cjihrig commented Nov 3, 2020

I think the report version should be bumped. Can you also update the example report in the documentation.

@gireeshpunathil
Copy link
Member Author

all - I have bumped the report version to 3, and reflected the change in the doc too. PTAL!

@addaleax
Copy link
Member

addaleax commented Nov 3, 2020

Why do we not add this to the loop entry in the handles list? That would a) be more consistent than this PR, because that’s where information about the loop currently goes and b) prevent a breaking change to the format that we can avoid that way.

@gireeshpunathil
Copy link
Member Author

@addaleax - to confirm my understanding, are you proposing this style?

  "libuv": [
    {
      "type": "async",
      "is_active": true,
      "is_referenced": false,
      "address": "0x0000000105a0bd70"
    },
    {
      "loop_idle_time": 22644.8
    }
  ]

@gireeshpunathil
Copy link
Member Author

or I guess here, as an additional key-value pair:

{
  "type": "loop",
  "is_active": true,
  "address": "0x000055fc7b2cb180",
  "loop_idle_time": 22644.8
}

?

@addaleax
Copy link
Member

addaleax commented Nov 4, 2020

@gireeshpunathil Yes, the latter, for the loop entry in the handles list.

@gireeshpunathil
Copy link
Member Author

@addaleax - done, ptal!

src/node_report.cc Outdated Show resolved Hide resolved
Copy link
Member

@richardlau richardlau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Maybe also add a validator for loop to the uv handles test to assert the new field is present and a number?

// Functions are named to aid debugging when they are not called.
const validators = {
fs_event: common.mustCall(function fs_event_validator(handle) {
if (!child_data.skip_fs_watch) {
assert.strictEqual(handle.filename, expected_filename);
assert(handle.is_referenced);
}
}),
fs_poll: common.mustCall(function fs_poll_validator(handle) {
assert.strictEqual(handle.filename, expected_filename);
assert(handle.is_referenced);
}),
pipe: common.mustCallAtLeast(function pipe_validator(handle) {
assert(handle.is_referenced);
}),
process: common.mustCall(function process_validator(handle) {
assert.strictEqual(handle.pid, child_data.pid);
assert(handle.is_referenced);
}),
tcp: common.mustCall(function tcp_validator(handle) {
// TCP handles. The report should contain three sockets:
// 1. The server's listening socket.
// 2. The inbound socket making the request.
// 3. The outbound socket sending the response.
const port = child_data.tcp_address.port;
if (handle.localEndpoint.port === port) {
if (handle.remoteEndpoint === null) {
found_tcp.push('listening');
} else {
found_tcp.push('inbound');
}
} else if (handle.remoteEndpoint.port === port) {
found_tcp.push('outbound');
}
assert(handle.is_referenced);
}, 3),
timer: common.mustCallAtLeast(function timer_validator(handle) {
assert(!handle.is_referenced);
assert.strictEqual(handle.repeat, 0);
}),
udp: common.mustCall(function udp_validator(handle) {
if (handle.remoteEndpoint === null) {
assert.strictEqual(handle.localEndpoint.port,
child_data.udp_address.port);
found_udp.push('unconnected');
} else {
assert.strictEqual(handle.remoteEndpoint.port,
child_data.udp_address.port);
found_udp.push('connected');
}
assert(handle.is_referenced);
}, 2),
};

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think doc/api/report.md still needs the relevant example updated to include this? (and the missing semicolon added to the test per linter)

@Trott Trott added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 4, 2020
@Trott Trott added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Nov 8, 2020
@gireeshpunathil gireeshpunathil added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 10, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 10, 2020
@nodejs-github-bot
Copy link
Collaborator

@trevnorris
Copy link
Contributor

I'm just curious. Why add it as loopIdleTimeSeconds instead of as it comes in high precision milliseconds?

@addaleax
Copy link
Member

@trevnorris What would you suggest instead? Seconds were suggested by me because they match other existing fields in the diagnostic output, so we’re being a bit consistent here instead of using random units everywhere.

@trevnorris
Copy link
Contributor

trevnorris commented Nov 11, 2020

@addaleax That's fine. I just noticed the field firesInMsFromNow in the libuv array for type: 'timer' and thought of following the timing of the closest field. But I have no strong feelings either way.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member Author

uv_metrics_idle_time is defined in uv.h and that is available through inclusion of env-inl.h. Adding node_perf.h is not required, plus it causes compilation failure in darwin, so I removed it.

@richardlau @cjihrig @addaleax @Trott - PTAL!

@gireeshpunathil gireeshpunathil added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2020
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one small question.


// Report Event loop idle time
uint64_t idle_time = uv_metrics_idle_time(env->event_loop());
writer.json_keyvalue("loopIdleTimeSeconds", 1.0 * idle_time / 1e9);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is idle_time in nanoseconds? I thought @trevnorris said it was milliseconds in #35940 (comment).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The libuv code uses uv_hrtime() without any additional scaling, so, yes, nanoseconds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node/src/node_perf.cc

Lines 446 to 447 in 589b2a1

uint64_t idle_time = uv_metrics_idle_time(env->event_loop());
args.GetReturnValue().Set(1.0 * idle_time / 1e6);

this may make it very clear - the nanoseconds that comes is converted to millis if accessed through API.

Copy link
Contributor

@cjihrig cjihrig Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I was just confused by #35940 (comment). Thanks Anna and Gireesh.

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2020
@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member Author

@gireeshpunathil gireeshpunathil added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 13, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 13, 2020
@nodejs-github-bot
Copy link
Collaborator

Add libuv's cumulative idle time in the diagnostic report.
Add the data under the libuv's loop section

Refs: nodejs#34938
PR-URL: nodejs#35940
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
@gireeshpunathil
Copy link
Member Author

landed in 74bd866

codebytere pushed a commit that referenced this pull request Nov 22, 2020
Add libuv's cumulative idle time in the diagnostic report.
Add the data under the libuv's loop section

Refs: #34938
PR-URL: #35940
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
codebytere added a commit that referenced this pull request Nov 22, 2020
Notable changes:

dns:
  * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099
events:
  * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001
http:
  * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048
http2:
  * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978
lib:
  * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716
path:
  * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962
readline:
  * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675
src:
  * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940
util:
  * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055

PR-URL: TODO
@codebytere codebytere mentioned this pull request Nov 22, 2020
codebytere added a commit that referenced this pull request Nov 24, 2020
Notable changes:

dns:
  * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099
events:
  * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001
http:
  * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048
http2:
  * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978
lib:
  * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716
path:
  * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962
readline:
  * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675
src:
  * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940
util:
  * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055

PR-URL: TODO
codebytere added a commit that referenced this pull request Nov 24, 2020
Notable changes:

dns:
  * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099
events:
  * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001
http:
  * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048
http2:
  * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978
lib:
  * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716
path:
  * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962
readline:
  * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675
src:
  * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940
util:
  * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055

PR-URL: #36232
codebytere added a commit that referenced this pull request Nov 24, 2020
Notable changes:

dns:
  * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099
events:
  * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001
http:
  * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048
http2:
  * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978
lib:
  * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716
path:
  * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962
readline:
  * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675
src:
  * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940
util:
  * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055

PR-URL: #36232
targos pushed a commit that referenced this pull request Mar 3, 2021
Add libuv's cumulative idle time in the diagnostic report.
Add the data under the libuv's loop section

Refs: #34938
PR-URL: #35940
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 6, 2021
Add libuv's cumulative idle time in the diagnostic report.
Add the data under the libuv's loop section

Refs: #34938
PR-URL: #35940
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. report Issues and PRs related to process.report. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants