Add performance and diagnostic counters for remote I/O - #1047
Merged
Conversation
madsbk
marked this pull request as ready for review
August 27, 2026 11:34
Comment on lines
+141
to
+143
| curl_easy_getinfo(easy, CURLINFO_NAMELOOKUP_TIME_T, &namelookup); | ||
| curl_easy_getinfo(easy, CURLINFO_CONNECT_TIME_T, &connect); | ||
| curl_easy_getinfo(easy, CURLINFO_APPCONNECT_TIME_T, &appconnect); |
Contributor
There was a problem hiding this comment.
Nit: The doc suggests that:
The data is stored accordingly and can be relied upon only if this function returns CURLE_OK.
So we may have a macro checking the error code, something like (untested):
#define KVIKIO_CHECK_CURL_EASY(error) \
kvikio::detail::check_curl_easy(error, __LINE__, __FILE__)
inline void check_curl_easy(CURLcode error, int line_number, char const* filename)
{
if (error != CURLE_OK) {
throw Exception{std::string{"libcurl error at: "} + filename + ":" + std::to_string(line_number) +
": " + std::string(curl_easy_strerror(error))};
}
}Or for simplicity, just have a function-scope lambda checking the error code, without the line number / file name arguments.
I know in CurlHandle we also use a buffer to store more detailed error message, but that could be a bit of overkill for get_info purpose.
Member
Author
There was a problem hiding this comment.
Good catch, added a noexcept helper.
KVIKIO_CHECK_CURL_EASY is worth having where throwing is right, the setopt and perform paths.
bdice
approved these changes
Aug 28, 2026
Member
Author
|
Thanks @kingcrimsontianyu and @bdice |
Member
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces always-on performance and diagnostic counters for remote I/O. These counters belong to no single operation, either because KvikIO does not track enough to correlate them with one, libcurl's connection statistics for instance, or because they are shared between many operations.
For a remote read a good deal of the time goes somewhere other than the transfer. The file has to be asked how big it is, a connection may have to be opened and a TLS handshake completed, and the endpoint may turn a request away and make KvikIO wait before trying again.
kvikio::statistics::counters()returns running totals for the process, so the cost of an interval is the difference between two readings. That is deliberately the whole design: no subscription, no record per event, no notification path, and nothing to enable. Relaxed atomics on a leaked singleton, read by whoever wants them.Summarycarries aCountersfor its span, so one report says what the run read and what reaching the data cost.What it looks like
What it costs
Nothing to collect. libcurl measures the connection phases whether or not anybody asks, and reports them cumulatively from the start of the transfer, so one
curl_easy_getinfocall after a transfer completes reads them all back out and differences them. It runs after every attempt rather than only after the one that succeeded, since an attempt that opened a connection and then failed would otherwise go uncounted. The size probe and the retry backoff are one line each at sites that already cost milliseconds.Follow-ups
Summary, so a sampling monitor carries these counters too. That is where a burst shows up that a run total flattens into a number.Observationitself. The retry counters here answer whether a run was throttled and for how long, not which read it was, so that issue stays open.