Skip to content

perf(tape): pwrite/pread in StdIo (#52 step 2a) - #54

Merged
shreyanshjain7174 merged 2 commits into
mainfrom
perf/52-pwrite
Oct 24, 2026
Merged

shreyanshjain7174 merged 2 commits into
mainfrom
perf/52-pwrite

Conversation

@shreyanshjain7174

@shreyanshjain7174 shreyanshjain7174 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Step 2a of #52.

StdIo::write_at did seek + write_all. That's 2 syscalls per request, about 160 per group of 80. On unix it now calls FileExt::write_all_at (pwrite). read_at uses pread. Non-unix keeps the seek path.

No semantic change. Placement and partial-failure handling are untouched. Nothing else in the crate reads or moves the file cursor.

Coalescing a group into 1 write (step 2b) is not in this PR. It changes partial-failure acks and needs its own tests. It's deferred, because halving syscalls here gains only about 1%.

Measured

Azure L8s v3, main 8a66c83 against this PR f98b082. Systems ran interleaved in shuffled order in one VM session, with Redis as a control, 5 reps. Ratios are medians of per-rep throughput ratios to main.

Disk Writers Turns/s main → PR Ratio p99 µs main → PR
Local NVMe 16 48,587 → 48,886 1.006 508 → 510
64 64,135 → 64,791 1.011 (1.004-1.013) 1,782 → 1,774
128 66,550 → 67,178 1.010 (1.008-1.014) 3,563 → 3,606
Premium SSD v2 16 9,588 → 9,629 1.009 (0.987-1.034) 2,590 → 2,522
64 31,480 → 32,505 1.020 (0.892-1.547) 3,610 → 3,334
128 44,515 → 44,964 1.015 (1.002-1.019) 5,124 → 4,956

perf stat on the writer thread at 128 writers and 640k appends: 641,771 write + 641,771 lseek become 641,771 pwrite64.

A small but free gain, with no regression on either disk. The Premium SSD v2 64-writer runs were noisy for every system. Full data is in #56 and on #52.

Validation

Each write_at was seek + write_all: 2 syscalls and no positional IO.
Unix now uses FileExt::write_all_at and read_at. Non-unix keeps the
seek path. No caller relies on the file cursor.

Refs #52

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shreyanshjain7174

Copy link
Copy Markdown
Contributor Author

A/B (details on #52): +0.6% / +1.1% / +1.0% at 16/64/128 writers. perf confirms 642k write+lseek become 642k pwrite64. Small but free. Marking ready.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The draft’s required Azure A/B measurements are still pending, so throughput gains and latency regressions need validation before approval.

No open issues 🎉

What changed in this PR

This PR reduces syscall overhead in StdIo as part of #52’s writer-throughput work, without changing write placement or partial-failure handling.

Changes:

  • Uses Unix positional I/O for complete writes and single reads, avoiding a separate seek.
  • Preserves locking and the seek-based fallback on non-Unix platforms.
  • Leaves write coalescing out of scope; performance measurements remain pending.
File Description
crates/​zerodb-tape/​src/​io.rs Adds Unix FileExt read/write paths and conditionally imports fallback I/O traits.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized change preserves explicit-offset access, full-write behavior, and locking, with no unresolved review findings.

No open issues 🎉

Review effort: Balanced

@shreyanshjain7174
shreyanshjain7174 merged commit 02f016f into main Oct 24, 2026
3 checks passed
@shreyanshjain7174
shreyanshjain7174 deleted the perf/52-pwrite branch October 24, 2026 17:51
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.

2 participants