Skip to content

Commit

Permalink
src: add loop idle time in diagnostic report
Browse files Browse the repository at this point in the history
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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
  • Loading branch information
gireeshpunathil authored and MylesBorins committed Apr 6, 2021
1 parent 5d29781 commit 4486801
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/api/report.md
Expand Up @@ -292,7 +292,8 @@ is provided below for reference.
{
"type": "loop",
"is_active": true,
"address": "0x000055fc7b2cb180"
"address": "0x000055fc7b2cb180",
"loopIdleTimeSeconds": 22644.8
}
],
"workers": [],
Expand Down
4 changes: 4 additions & 0 deletions src/node_report.cc
Expand Up @@ -294,6 +294,10 @@ static void WriteNodeReport(Isolate* isolate,
static_cast<bool>(uv_loop_alive(env->event_loop())));
writer.json_keyvalue("address",
ValueToHexString(reinterpret_cast<int64_t>(env->event_loop())));

// 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);
writer.json_end();
}

Expand Down
3 changes: 3 additions & 0 deletions test/report/test-report-uv-handles.js
Expand Up @@ -128,6 +128,9 @@ if (process.argv[2] === 'child') {
assert.strictEqual(handle.filename, expected_filename);
assert(handle.is_referenced);
}),
loop: common.mustCall(function loop_validator(handle) {
assert.strictEqual(typeof handle.loopIdleTimeSeconds, 'number');
}),
pipe: common.mustCallAtLeast(function pipe_validator(handle) {
assert(handle.is_referenced);
}),
Expand Down

0 comments on commit 4486801

Please sign in to comment.