Skip to content

Reader/eager first chunk#8

Merged
virtexalejandro merged 3 commits intomainfrom
reader/eager-first-chunk
Apr 28, 2026
Merged

Reader/eager first chunk#8
virtexalejandro merged 3 commits intomainfrom
reader/eager-first-chunk

Conversation

@virtexalejandro
Copy link
Copy Markdown
Contributor

No description provided.

virtexalejandro and others added 3 commits April 27, 2026 18:11
…/ OnReady API

OpenReplayFile() previously returned the instant the header+footer were
parsed, leaving zero frames serviceable.  Loaded() was true but the first
GetFrame*() call would still pay the chunk-0 load cost synchronously.

This change kicks off chunk 0 load eagerly on OpenReplayFile() and exposes
three consumption styles so callers choose whatever fits:

  - poll:     IsReady() / IsReadyFailed() / GetReadyError()
  - block:    WaitUntilReady() / WaitUntilReady(timeout)
  - listen:   ReplayReaderEvents::OnReady / OnReadyFailed

Failure of the async chunk-0 load does NOT fail OpenReplayFile() -- the
reader is still usable for metadata inspection (header, schema, seek
table), consistent with the async philosophy.  Empty replays flip ready
synchronously via MarkReadyVacuous() so waiters never hang.

The eager warm is narrowed to a (0,0) cache window around the WarmAt(0)
call and restored to the default (2,2) immediately after.  This preserves
the intent that only the first chunk is pre-loaded -- callers that set a
narrow cache window right after OpenReplayFile() (memory-constrained
tools, isolation tests) stay unaffected.  No external handle to the
reader exists during the narrow window so the temporary narrow is
unobservable.

Tests: 6 new cases in test_reader_context.cpp (poll happy path, direct-
facade callback, post-open callback single-shot, empty replay,
destruction-during-load race, sync GetFrame hits warm cache, WarmAt after
ready doesn't regress the flag, OnReadyFailed on corrupt chunk 0).  Two
of the failure tests GTEST_SKIP when aggressive corruption also breaks
the synchronous header/footer parse.

Samples: samples/ready_api.cpp demos all three styles (--style=a|b|c|all).

Benchmarks: bench_reader_ready.cpp measures OpenReplayFile alone,
OpenReplayFile+WaitUntilReady, and OpenReplayFile+GetFrameSync(0) on the
synth_10k.vtx fixture.  Numbers on this box: ~2.98ms open-only, ~5.65ms
open-to-ready, ~5.91ms open-to-first-frame.

TSan: not runnable on MSVC (VTX_SANITIZE gated NOT MSVC); Linux CI job
covers -DVTX_SANITIZE=thread.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mechanical fixes flagged by the diff-only clang-format gate in
.github/workflows/build.yml.  No semantic changes.
@virtexalejandro virtexalejandro merged commit 7455e06 into main Apr 28, 2026
9 checks passed
@virtexalejandro virtexalejandro deleted the reader/eager-first-chunk branch April 28, 2026 10:40
virtexalejandro added a commit that referenced this pull request Apr 28, 2026
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.

1 participant