Skip to content

io: merge IoKind::WriteArc into IoKind::WriteShared #1003

Backlog

Description

@citizen-stig

IoKind has two variants that write a shared, immutable page and differ only in the type that keeps the page alive:

WriteArc(RawFd, u64, Arc<FatPage>),
WriteShared(RawFd, u64, Arc<dyn AsRef<[u8; PAGE_SIZE]> + Send + Sync>),

WriteShared was introduced in #998 (replacing WriteRaw) so that a beatree write command holds an Arc to its BranchNode / LeafNode until the write completes. WriteArc is the older variant, used by bitbox for hash-table pages (bitbox/writeout.rs, write_ht).

Proposal

Implement AsRef<[u8; PAGE_SIZE]> for FatPage and drop WriteArc; an Arc<FatPage> then coerces to the WriteShared payload directly.

What this touches:

  • nomt/src/io/page_pool.rs: the AsRef<[u8; PAGE_SIZE]> impl for FatPage. BranchNode and LeafNode could then delegate to it instead of each converting the slice themselves.
  • nomt/src/io/mod.rs: remove the WriteArc variant and its arms in Debug and unwrap_buf.
  • nomt/src/io/linux.rs, nomt/src/io/unix.rs: remove the WriteArc arms in submission_entry / execute.
  • nomt/src/bitbox/writeout.rs (write_ht), the only WriteArc sender: switch to WriteShared.

Notes

  • WriteShared goes through a trait object, so hash-table page writes would gain one dynamic call per submission. That should be negligible next to the write itself, but it is worth a quick check with the benchmarks.
  • This is a pure refactor with no behaviour change. It was left out of hardening tests and fixes #998 to keep that PR limited to the ported hardening fixes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions