Add structured, physical read traces - #1016
Open
TomAugspurger wants to merge 4 commits into
Open
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
Author
|
/ok to test 19db970 |
Contributor
Author
|
/ok to test 908041a |
TomAugspurger
marked this pull request as ready for review
July 29, 2026 17:17
TomAugspurger
commented
Jul 29, 2026
Contributor
Author
There was a problem hiding this comment.
This is deliberately private. It's been useful for me, and might be useful for others, but I don't think we should commit to maintaining it.
|
|
||
| {"event":"read","level":"trace","source":"s3://bucket/data.parquet","start":1747901139123456789,"end":1747901139127890123,"offset":4194304,"size":1048576,"threadId":17390204170953158183,"bytesRead":1048576,"backend":"remote","status":"ok","isDeviceBuffer":true,"requestId":42,"method":"GET"} | ||
|
|
||
| HTTP metadata JSON objects have ``"event":"http"`` and the following fields: |
Contributor
Author
There was a problem hiding this comment.
I wonder if this should just go under event: read with method: HEAD. Why split it out into its own thing?
Contributor
Author
|
This will need to be benchmarked to see how much overhead we've introduced. |
rapids-bot Bot
pushed a commit
that referenced
this pull request
Aug 18, 2026
This PR introduces a hook into monitoring KvikIO operations, with the goal of building statistics, Quent timelines, and whatever else wants to know what the I/O layer is doing. This PR is the base. A follow-up introduces a concrete `Monitor` that makes statistics easy to get. The hook reports whole KvikIO operations (the logical level) so a `pread()` is a single observation however many reads the thread pool issued underneath. Physical operations can be added along the same path later, which could be the basis of #1016. Each call produces a `kvikio::Observation`: its span, the offset and size etc. To receive them, derive from `kvikio::Monitor` and register it. A monitor is told when an operation *starts* as well as when it finishes. ```c++ // Example of a Monitor that tracks how many KvikIO operations are in flight at any moment. class QueueDepth : public kvikio::Monitor { void on_start(kvikio::Observation const&) noexcept override { ++_in_flight; } void on_finish(kvikio::Observation const&) noexcept override { --_in_flight; } std::atomic<int> _in_flight{0}; }; QueueDepth gauge; auto id = kvikio::register_monitor(&gauge); ``` ### Overhead Measured on my local workstation: - **~3 ns per call when nobody is observing**, which is a gate check and a branch. - **~60 ns per call when somebody is**, or 1 % of a 64 KiB `pread()`, and nothing detectable at a megabyte. Confirmed against a real workload: cudf-polars PDS-H query 1 at scale 10, with and without a monitor attached, showed no difference outside noise. ### What is not observed The cuFile asynchronous API on a GDS system, and the batch API, complete without KvikIO seeing it, so they emit nothing. Handling those needs a stream-completion callback, which is future work. ### Follow-up: statistics The next PR adds `kvikio::statistics::SummaryMonitor`, which is a `Monitor` and nothing more: ```python monitor = kvikio.SummaryMonitor() # statistics are now on ... print(monitor.get()) ``` ``` KvikIO I/O summary wall time 1.876 s busy time 366.592 ms (19.54 % of the wall time) busy bandwidth 8.95 GB/s operations 7970 bytes requested 3.06 GiB bytes transferred 3.06 GiB errors 0 ``` Those are real numbers, from a cudf-polars run, and they show a very useful `busy bandwidth`. **8.95 GB/s** is the rate while KvikIO actually had work in flight, where dividing the same bytes by the wall clock would have said **1.75 GB/s** and described the query rather than the storage. A `TimelineMonitor`, for *when* things happened rather than how much, is planned after that. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) - Tianyu Liu (https://github.com/kingcrimsontianyu) URL: #1033
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 updates our logging setup to optionally emit structured, physical traces.
There are two main sets of changes:
TRACElevel. This takes the "logical" reads from the user's program and traces the actual reads done by kvikio, which might be smaller thanks to kvikio's read splittingHere's an example program:
When run with
KVIKIO_LOG_LEVEL=TRACE KVIKIO_LOG_FORMAT=JSON KVIKIO_LOG_FILE=trace.ndjson python test_remote.pythat writesCloses #967