Skip to content

Report native read bytes in Spark V2 scan metrics - #108

Merged
ChristopherWirt merged 1 commit into
developfrom
cwirt/fix-issue-99
Nov 10, 2026
Merged

ChristopherWirt merged 1 commit into
developfrom
cwirt/fix-issue-99

Conversation

@ChristopherWirt

@ChristopherWirt ChristopherWirt commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Spark V2 scans of Vortex files report 0 input bytes. Vortex reads on native worker threads, but Spark only counts Hadoop FileSystem statistics from the task thread.

Fix

  • PooledReadable reports each successful read through a new onBytesRead hook. HadoopReadable forwards it to a caller-supplied LongConsumer.
  • VortexReadMetrics publishes worker-thread bytes from the task thread into a dedicated FileSystem.Statistics entry, so Spark's own refresh keeps them in inputMetrics.bytesRead.
  • Scans also expose a vortexBytesRead custom metric.
  • PooledReadable.close() now waits for in-flight reads, so the final task snapshot includes read-ahead. An interrupted close does not wait.

Totals include footer reads and read-ahead. They accumulate across files and coalesced partitions, and stay separate per scan within one task.

Testing

Focused tests pass on Spark 3.5.9 / Scala 2.12 and Spark 4.0.4 / Scala 2.13:

  • Exact task and custom byte totals for multi-file, coalesced, multi-scan, pushed COUNT(*), empty-result and LIMIT queries.
  • Concurrent reads, EOF, draining close, interrupted close, and interrupted close with nothing in flight.

Fixes #99

🤖 Generated with Claude Code

ChristopherWirt added a commit that referenced this pull request Nov 10, 2026
## Summary

Fix the shared Linux musl builder failure on `develop` and PRs #103,
#105, #106, #107, and #108 after the upstream lazy-constructor update.

## Changes

Normalize lists rebuilt from list views through the same `reset_offsets`
path as ordinary lists before forwarding their children to layout
writers. Rebuilding a sliced list view can now leave a lazy elements
slice; a flat child writer cannot serialize that expression. This
preserves the existing referenced-element bounds and resolves the slice
without forcing unrelated encodings into canonical arrays.

Keep the existing nullable sliced-list-view regression and add the
non-nullable case.

## CI Failure Analysis

### Status

Pre-existing base-branch regression, independent of the individual PR
changes. The same failure appears on [develop run
42649358621](https://github.com/quantcast/vortex/actions/runs/42649358621)
and every completed failing PR builder inspected (#105–#108).

### Failed Jobs

- `Rust tests (linux-musl)`: test failure in
`layouts::list::reader::tests::sliced_list_chunks_round_trip::case_4_list_view_chunks`.

### Relevant Log Output

```text
Error: Array vortex.slice is not registered for serialization
```

### Correlation With PR Changes

The upstream merge makes array slicing lazy. The list-view branch of
`canonicalize_to_list_parts` forwarded a rebuilt list's lazy elements
directly, while the ordinary-list branch already normalized them. The
Spark PRs do not change this writer; #107 changes separate zone-pruning
code.

### Recommended Next Step

Merge this shared fix into `develop`. The same patch is being applied to
the affected open PR branches so their new builders include the fix
immediately.

## Validation

- Reproduced the exact failing test on unmodified current `develop`
(exit 100, same serialization error).
- `cargo nextest run -p vortex-layout -E 'test(layouts::list::)'`: all
161 tests passed after the fix, including the original failing case and
new non-nullable case.
- `cargo clippy -p vortex-layout --all-targets --all-features -- -D
warnings`: passed.
- Pinned nightly Rust formatting and `git diff --check`: passed.

Local validation ran on macOS; the fresh Linux musl builders will verify
the runner-specific job.

Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
@ChristopherWirt
ChristopherWirt merged commit 729c93b into develop Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spark V2 scans report no input bytes to Spark's metrics

1 participant