loop,threadpool: trace events#1815
Conversation
|
Ping @bnoordhuis @cjihrig @evanlucas @saghul ... I'd like to close the loop on this soon, if at all possible. This is an alternate take on the ideas in #1764 that uses more of a trace-events style model (as suggested by @bnoordhuis) |
|
Ping again... I'd like to get this landed. This particular version does require an ABI change and would require libuv 2.0... however, it would be possible to set this particular version up so that changes to |
|
@cjihrig @evanlucas @saghul @bnoordhuis ... would it be possible to get some idea of when this may be looked at? |
santigimeno
left a comment
There was a problem hiding this comment.
Also the loop_trace test is failing locally:
not ok 139 - loop_trace
# exit code 6
# Output from process `loop_trace`:
# Assertion failed in test/test-loop-trace.c on line 129: saw_start_event & (1 << UV_TRACE_POLL)
| #define START_SIZE 8 | ||
| static unsigned idle_max = 0; | ||
| static unsigned idle_min = 2 * START_SIZE; | ||
| static unsigned queued_max = 0; |
There was a problem hiding this comment.
No need to initialize static variables to zero
| 'test-loop-close.c', | ||
| 'test-loop-stop.c', | ||
| 'test-loop-time.c', | ||
| 'test-loop-trace.c', |
There was a problem hiding this comment.
test-threadpool-trace.c should be added too
| } | ||
|
|
||
| test_result = run_test(task->task_name, benchmark_output, current); | ||
| fflush(stderr); |
There was a problem hiding this comment.
I'm not sure this change belongs here.
| uv_req_t* req; | ||
| uv_req_t* first; | ||
| uv_req_t* next; | ||
| size_t count = 0; |
There was a problem hiding this comment.
separate declaration from assignment
| QUEUE* q; | ||
| QUEUE pq; | ||
| uv__io_t* w; | ||
| size_t count = 0; |
There was a problem hiding this comment.
Style: separate declaration from assignment
| } | ||
|
|
||
| void uv__trace_end(uv_loop_t* loop, | ||
| const uv_trace_info_t* info) { |
There was a problem hiding this comment.
Style: this can go on 1 line only
| @@ -0,0 +1,148 @@ | |||
| /* Copyright (c) 2014, Ben Noordhuis <info@bnoordhuis.nl> | |||
| static size_t check_count = 0; | ||
| static size_t idle_count = 0; | ||
| static size_t prepare_count = 0; | ||
| static size_t pending_count = 0; |
There was a problem hiding this comment.
No need to initialize static variables to zero.
|
|
||
| if (timeout == 0) | ||
| if (timeout == 0) { | ||
| uv__trace_end(loop, (uv_trace_info_t*)&trace_info); |
There was a problem hiding this comment.
Maybe instead of adding the uv__trace_end() call on every return, add a label and use goto.
| enum { | ||
| UV_LOOP_BLOCK_SIGPROF = 1 | ||
| UV_LOOP_BLOCK_SIGPROF = 1, | ||
| UV_LOOP_TRACE_NOTIFY = 2 |
There was a problem hiding this comment.
I can't see this flag being used in the code.
There was a problem hiding this comment.
look in unix/loop.c ... it's set as a loop->flags... purely informational right now.
b6e9f94 to
513e997
Compare
|
@santigimeno ... what platform are you testing on where it's failing locally? |
@jasnell on |
bnoordhuis
left a comment
There was a problem hiding this comment.
I've thought about this PR and I say let's not do this for now. Landing it very much complicates the thread pool redesign discussed in #1959. That's an important and long-standing issue.
What's more, if the pluggable thread pool approach goes through, which seems likely, the tracing functionality in libuv becomes obsolete. Node.js won't use it because it'll move to its own custom thread pool and other users are unlikely.
(Besides, such users can plug in their own thread pool with added instrumentation. To me that's a strictly superior option.)
|
That seems to only impact the threadpool aspect of this, not the loop tracing. |
I agree -- Node would still benefit from loop tracing. And I don't see a problem in supporting tracing in the default libuv threadpool, thus benefiting embedders who don't plug in their own TPs. |
@jasnell It reminds me of the dtrace/systemtap probes I removed in cb51400. Lots of infrastructure and maintenance for something that was ultimately of marginal value. They traced event loop ticks too but at least they were zero cost when disabled. This PR on the other hand adds some ever-present overhead. And since it targets master and is a pretty big diff, it'll be an ongoing merge conflict magnet as long as the v1.x branch is alive. I'm not really convinced it's worth it for those two (three?) reasons. I just can't get excited about it. Maybe other maintainers feel differently.
@davisjam I'm sympathetic to that argument but I don't think anyone asked for thread pool tracing except Node.js + derivatives, and I expect that for them it's only a stop-gap measure. I'm open to reconsidering it if other users do pop up, however. It would be good to get more feedback on the API anyhow. |
|
Its a pity not having this PR, or at least the loop events, moving forward ..... what can we do ? or what is needed to justify the adoption of loop traces? |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is an alternative take to #1764 that uses a more trace-events style API as suggested by @bnoordhuis.
This approach greatly simplifies the record keeping required in V8 and minimizes the possible ABI breakages that could occur. It would integrate quite well with V8 Trace Events in Node.js but would increase the record keeping necessary there to integrate with things like the Performance API (record keeping would still be minimal).
The
UV_LOOP_TRACEandUV_THREADPOOL_TRACEconfiguration options are separate largely to keep internal tracking simple. Loop tracing is specific to individual loops, while the threadpool may have multiple listeners. Keeping them separate allows for greatly simplified tracking without internals getting muddy.