Commit 176575f
authored
feat(io): S3 LIST + footer probe + kvikIO backend, and io-layer fixes (#172)
Adds three capabilities to the `io` datasource layer, fixes several latent defects found while auditing it, and gives the layer its first test coverage.
## Bug fixes
- **`io_request`: `copy_async` validates its host source before forming the pointer.** A null `host_buffer`, or an out-of-range `[src_off, src_off + size)`, previously produced UB (`nullptr + offset`) or a wild in-range pointer that the near-null check could not catch. Now returns `cudaErrorInvalidValue`. The existing asserts compile out in release, so the check has to happen before the pointer is formed.
- **`prefetching_cache`: mark the *request* state load-failed on the `prefetch_loop` cancel/stop path.** Only the chunk states were being marked, leaving the request-level state inconsistent on cancellation.
- **Four empty `catch` blocks were silently swallowing exceptions** — the `rest_reactor` and `uring_reactor` worker loops, and two in `templated_ioctx::shutdown`. Restoring the log call sites fills them. `CUCASCADE_LOG_*` are no-ops today, so this costs nothing at runtime but keeps the diagnostics in place for when logging is wired up.
## Behavioral fixes
- **`rest_reactor::preferred_prefetching_stage`: `opportunistic` → `just_in_time`.** `prefetching_cache` branches on exactly this value, so S3 reads were being eagerly prefetched into cache buffers rather than read straight into the caller's buffer. Network round-trips are high-latency; read ahead on demand rather than prefilling the working set.
- **`uri_parser`: S3 object keys are literal bytes.** `%`, `?` and `#` are ordinary key bytes, matching AWS CLI semantics, so `s3://b/a%20b` now opens the key `a%20b`. Previously the key was percent-decoded and split on `?`, which opened the wrong object.
## New capability
- **S3 ListObjectsV2** — a hand-rolled, fail-closed list parser (no XML dependency); `presign_url(extra_canonical_query)` so caller query params participate in the signature (required for S3 to accept a presigned LIST); `authorize_list` on the authorizer interface and both SigV4 implementations; an `X-Amz-*` injection guard so callers cannot smuggle or override signing params; `rest_reactor::list_page`; and `rest_ioctx::list_objects_paged` / `list_objects` / `list_max_matches`. Pagination is guarded against non-conforming backends: truncated-without-token, truncated-but-empty, and non-advancing continuation token all throw rather than loop or silently truncate.
- **Parquet footer probe** — `open_hint` plus `create_io_object(path, hint)`; a suffix-range GET that resolves the object size *and* stashes its trailing bytes in one round-trip; and a stash-hit fast path in `rest_reactor::host_read` so the footer reads that follow are served from memory instead of costing extra round-trips. Falls back to a plain HEAD on any unusable response (200 full body, 416, missing/unsatisfied `Content-Range`).
- **Known-size open** — `create_io_object(path, known_size)`, so a size already learned from a LIST response builds the io_object with zero network: no HEAD, no probe.
- **`kvikio_context`** — a local-file fallback backend built directly on `kvikio::FileHandle` rather than `cudf::io::datasource`, which keeps the io library cudf-free. Registered as a catch-all that `lookup_path` defers behind the explicit uring/rest backends, so `s3://` never resolves to it and a local file still routes to uring first.
- **`kvikio_config`** — optional-per-field tunables: `nthreads`, `task_size`, `gds_threshold`, `bounce_buffer_size`, O_DIRECT reads and overread, per-block-device pools, and compat mode. An unset field means "leave kvikIO's own default alone", so the `KVIKIO_*` environment variables keep working as the outer default and this is an explicit in-process override layered on top. Every field except `compat_mode` maps to a setter on kvikIO's process-global `defaults` singleton and is documented as such — last context constructed wins. `compat_mode` is the exception: it rides the `FileHandle` constructor, so it scopes to files this ioctx opens and mutates nothing global.
## Cleanup
- `metadata_store::get_metadata(cache_key)` overload, for callers that know the path but have not built an io_object yet.
- Dropped `object_store_config::s3_use_async_backend` — no consumers, and it referenced types that do not exist.
- Renamed `io_context_registry::lookup` → `lookup_path`. It is passed a full path, not a bare scheme (the checkers parse the URI / stat the filesystem themselves), and the docs claimed otherwise.
## Tests
New `cucascade_io_tests` target — **732 assertions across 71 cases**, covering `uri_parser`, sigv4, the list parser, both authorizers, static credentials and `kvikio_config`. **The io layer had no tests at all before this.**
Full suite: **6,330 assertions / 343 cases, 0 failures.**
| Binary | Result |
|---|---|
| `cucascade_tests` | 3225 / 89 |
| `cucascade_io_tests` (new) | 732 / 71 |
| `cucascade_cudf_tests` | 2326 / 177 |
| `cucascade_topology_discovery_tests` | 47 / 6 |
Builds clean with `CUCASCADE_WARNINGS_AS_ERRORS=ON`; `pre-commit run -a` passes.
## Not verified
The two S3 benchmarks are gated behind `CUCASCADE_BUILD_S3_BENCHMARK`, which requires aws-sdk-cpp (present only in the `s3-bench` pixi environment), so **they were not compiled**. By inspection they use only the single-argument `open_datasource` / `open_io_object` overloads — unchanged, since the new behavior was added as overloads rather than signature changes — and nothing switches over `io_context_type`, so the new `kvikio` enumerator cannot trip `-Werror=switch`.
## Follow-up
REST perf instrumentation (per-chunk timings, queue wait, TTFB, retry/terminal counters, pool aggregation) is deliberately not part of this PR. The control-plane paths added here leave room for it and it layers on cleanly; the existing S3 benchmarks are its natural consumer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Authors:
- Amin Aramoon (https://github.com/aminaramoon)
Approvers:
- https://github.com/felipeblazing
URL: #1721 parent cc4ca57 commit 176575f
42 files changed
Lines changed: 3915 additions & 80 deletions
File tree
- include/cucascade
- cudf
- io
- cache
- kvikio
- rest
- s3
- src
- cudf
- io
- cache
- kvikio
- rest
- s3
- uring
- test
- io
- cache
- kvikio
- rest
- s3
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
161 | 166 | | |
162 | 167 | | |
163 | 168 | | |
| |||
402 | 407 | | |
403 | 408 | | |
404 | 409 | | |
405 | | - | |
| 410 | + | |
406 | 411 | | |
407 | 412 | | |
408 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
162 | 177 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
30 | 51 | | |
31 | 52 | | |
32 | 53 | | |
| |||
58 | 79 | | |
59 | 80 | | |
60 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
61 | 88 | | |
62 | 89 | | |
63 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
64 | 95 | | |
65 | 96 | | |
66 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
| |||
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | | - | |
79 | | - | |
| 74 | + | |
| 75 | + | |
80 | 76 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
85 | 80 | | |
86 | 81 | | |
87 | 82 | | |
88 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
| |||
102 | 111 | | |
103 | 112 | | |
104 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
105 | 130 | | |
106 | 131 | | |
107 | 132 | | |
| |||
263 | 288 | | |
264 | 289 | | |
265 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
266 | 305 | | |
267 | 306 | | |
268 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 150 | + | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
| |||
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
162 | | - | |
163 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
164 | 178 | | |
165 | 179 | | |
166 | 180 | | |
| |||
0 commit comments