libuv/src/win
Trevor Norris e8effd4556 core: add API to measure event loop idle time
The API addition `uv_metrics_idle_time()` is a thread safe call that
allows the user to retrieve the amount of time the event loop has spent
in the kernel's event provider (i.e. poll). It was done this way to
allow retrieving this value without needing to interrupt the execution
of the event loop. This option can be enabled by passing
`UV_METRICS_IDLE_TIME` to `uv_loop_configure()`.

One important aspect of this change is, when enabled, to always first
call the event provider with a `timeout == 0`. This allows libuv to know
whether any events were waiting in the event queue when the event
provider was called. The importance of this is because libuv is tracking
the amount of "idle time", not "poll time". Thus the provider entry time
is not recorded when `timeout == 0` (the event provider never idles in
this case).

While this does add a small amount of overhead, when enabled, but the
overhead decreases when the event loop has a heavier load. This is
because poll events will be waiting when the event provider is called.
Thus never actually recording the provider entry time.

Checking if `uv_loop_t` is configured with `UV_METRICS_IDLE_TIME` always
happens in `uv__metrics_set_provider_entry_time()` and
`uv__metrics_update_idle_time()`. Making the conditional logic wrapping
each call simpler and allows for instrumentation to always hook into
those two function calls.

Rather than placing the fields directly on `uv__loop_internal_fields_t`
add the struct `uv__loop_metrics_t` as a location for future metrics API
additions.

Tests and additional documentation has been included.

PR-URL: https://github.com/libuv/libuv/pull/2725
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
2020-08-04 10:31:42 -04:00
..
async.c unix,win: merge handle flags 2018-06-29 22:24:52 +02:00
atomicops-inl.h src,test: fix idiosyncratic comment style 2018-05-29 11:56:49 -07:00
core.c core: add API to measure event loop idle time 2020-08-04 10:31:42 -04:00
detect-wakeup.c build: add -Wstrict-prototypes 2017-05-02 23:00:33 +02:00
dl.c warnings: fix code that emits compiler warnings 2018-11-29 11:21:44 -05:00
error.c win, fs: add IO_REPARSE_TAG_APPEXECLINK support 2020-04-29 13:50:20 +02:00
fs-event.c win: remove MAX_PATH limitations 2020-04-28 18:06:42 +02:00
fs-fd-hash-inl.h win: add UV_FS_O_FILEMAP 2019-07-16 18:20:10 +02:00
fs.c win, fs: add IO_REPARSE_TAG_APPEXECLINK support 2020-04-29 13:50:20 +02:00
getaddrinfo.c unix,win: support IDNA 2008 in uv_getaddrinfo() 2018-10-30 20:50:23 +01:00
getnameinfo.c unix,win: limit concurrent DNS calls to nthreads/2 2018-08-21 10:48:24 +02:00
handle-inl.h unix,win: merge handle flags 2018-06-29 22:24:52 +02:00
handle.c unix, win: make fs-poll close wait for resource cleanup 2019-03-11 09:50:01 +00:00
internal.h win, util: rearrange uv_hrtime 2020-05-25 17:59:11 +02:00
loop-watcher.c unix,win: merge handle flags 2018-06-29 22:24:52 +02:00
pipe.c win,pipe: erase event_handle after deleting pointer 2020-02-27 09:13:04 +01:00
poll.c win: DRY uv_poll_close() 2020-04-22 12:23:00 +02:00
process-stdio.c win: fixing build for older MSVC compilers 2018-06-29 10:35:18 +02:00
process.c win: replace alloca() with stack-based array 2020-04-14 20:44:00 -04:00
req-inl.h unix,windows: refactor request init logic 2017-03-21 16:14:09 +01:00
signal.c unix,win: add uv_library_shutdown() 2020-04-22 12:24:36 +02:00
snprintf.c win: fix compilation with VS < 2012 2015-10-01 00:41:41 +02:00
stream-inl.h req: revisions to uv_req_t handling 2018-02-25 18:49:37 +01:00
stream.c tcp: add uv_tcp_close_reset method 2019-08-19 23:41:15 +02:00
tcp.c win,tcp: avoid reinserting a pending request (#2688) 2020-07-28 13:59:08 -04:00
thread.c thread: allow specifying stack size for new thread 2019-02-08 21:15:01 +01:00
tty.c win,tty: fix deadlock caused by inconsistent state 2020-06-15 18:27:54 +02:00
udp.c udp: add uv_udp_using_recvmmsg query 2020-07-28 23:28:18 -04:00
util.c win: fix visual studio 2008 build 2020-06-12 12:31:58 +02:00
winapi.c win: use RtlGenRandom from advapi32.dll directly 2020-04-06 12:40:48 +02:00
winapi.h win, fs: add IO_REPARSE_TAG_APPEXECLINK support 2020-04-29 13:50:20 +02:00
winsock.c win: remove abort when non-IFS LSP detection fails 2020-01-08 12:00:28 -05:00
winsock.h win,mingw: Fix undefined MCAST_* constants 2019-09-25 14:48:10 +02:00