Skip to main content

Crate pigeonhole_io

Crate pigeonhole_io 

Source
Expand description

Vfs abstraction for Pigeonhole: files, aligned buffers, completions, pread pool and fault-injecting simulated backend.

Every byte any other crate reads or writes goes through a Vfs, so the simulator can inject faults and control time. Backends:

  • pread::PreadVfs: real files, a pread/pwrite thread pool for submitted I/O. The safe reference backend on every platform.
  • sim::SimVfs: in-memory, deterministic from a seed, with torn writes, reordered fsyncs, ENOSPC and crashes. With sim::FaultPlan::none it is the plain in-memory mock other crates test against.
  • uring::UringVfs (Linux only, so not linked here): real files with submitted I/O on io_uring (#402).

This crate also owns the other OS-facing unsafe the engine needs: shared-memory mappings (SharedRegion), byte-range locks, thread pinning and NUMA binding (sys).

Part of Pigeonhole. See the crate README.

Re-exports§

pub use own::OwnIoWaker;
pub use own::in_inline_io;
pub use own::inline_io;
pub use own::own_io_fd;
pub use own::own_io_in_flight;
pub use own::own_io_waker;
pub use own::reap_orphan_io;
pub use own::reap_own_io;

Modules§

pread
The pread thread-pool backend: real files on every platform, the safe reference.
sim
The simulated backend: in-memory files and shared memory, deterministic from a seed, with fault injection. pigeonhole-sim builds its scheduler, crash points and model on top.
sys
Thread placement: CPU pinning and topology. Lives here because it needs unsafe FFI and this is one of the three crates allowed it.
uring
The io_uring backend (Linux, #402): real files whose submitted I/O goes through an io_uring ring instead of a thread pool.

Structs§

BufPool
A bounded pool of heap IoBufs (ICR 0026): a buffer taken from it goes back when it is dropped, wherever that happens, unless the pool is full. A reader that decodes block after block reuses a few allocations instead of allocating and zero-filling one per block (#372).
Completion
The pending result of a submitted operation: a read or write (resolving to its buffer), a sync (resolving to ()), or a higher-level operation built on them (a WAL group sync resolving to an Lsn, a root commit).
Error
An I/O error: a kind for branching, a static context and the OS error if any.
FileIdentity
Device and inode of a file: the same on every process however the path is spelled.
IoBuf
An owned, page-aligned (4096-byte) buffer for file I/O.
IoCounters
One database’s bytes read and written by its files since the counters were given to them.
OpenOptions
How to open a file.
OwnIoWaker
Interrupts its thread’s wait in reap_own_io (an io_uring ring’s wait for completions, #402) from any thread: the scheduler’s wakeup for a shard thread that waits on its ring rather than parking.
ProcessId
A process as recorded in a reader slot: its id plus its start time, so a recycled pid is not mistaken for the original process.
Resolver
Resolves a Completion created with Completion::pair.
RingStats
A backend’s io_uring rings now (Vfs::ring_stats).
SharedRegion
A mapped shared-memory region (or a heap stand-in), cheap to clone.

Enums§

ErrorKind
Broad classes of I/O failure that callers branch on.
Locality
The kind of filesystem a file lives on (File::locality).
LockMode
Mode of a byte-range lock.
SharedOpen
How Vfs::open_shared treats an existing region.

Traits§

File
An open file. Shared across threads; all methods take &self and use positional I/O.
Vfs
The environment: files, shared memory, clocks and process liveness.

Functions§

in_inline_io
Whether the calling thread is inside an inline_io scope.
inline_io
Runs f with every operation the calling thread submits run inline, synchronously, on this thread (D284): never on a ring of its own (an io_uring thread ring is not used, nor is one attached), never on the backend’s shared ring or its I/O threads. On the real backends (io_uring and PreadVfs) each submitted operation has completed when its submit_* call returns, so when f returns nothing it submitted is in flight, whichever thread reaps what.
own_io_fd
A file descriptor that turns readable when the calling thread has completions to reap (an io_uring ring’s registered eventfd, #408), for a thread that waits in its own event loop (poll, epoll) rather than in reap_own_io: wait until it is readable, then reap. Reaping resets it. None when the thread’s backends offer no such descriptor (the thread then has to reap again soon while own_io_in_flight says it has I/O in flight).
own_io_in_flight
Whether the calling thread has submitted operations in flight that only it can complete (by reap_own_io). Always false on backends whose completions arrive on other threads, such as PreadVfs.
own_io_waker
A handle that interrupts the calling thread’s waits in reap_own_io, from the first of its backends that offers one (None when no backend’s wait can be interrupted: a scheduler then parks the thread as usual).
reap_orphan_io
Reaps every backend no thread reaps (the simulator under deferred I/O), waiting up to wait for something to complete: for a thread blocked on an outcome chained after I/O it holds no completion of, such as a WAL sync waiting for the stream’s older syncs (ICR 0028), which would otherwise wait for ever. None when no such backend is registered (one relaxed load: then wait as usual); otherwise whether anything completed.
reap_own_io
Completes the calling thread’s finished operations on every backend that leaves them to it, waiting up to wait for one to finish when none has. None takes only what has already finished, without waiting (a shard’s turn); the simulator’s device finishes its operations only for a thread that waits. Their completions resolve, and their continuations run, on this thread. Returns whether any completed.

Type Aliases§

FileRef
A shared handle to an open file.
Result
Result alias for this crate.
VfsRef
A shared handle to a Vfs.