:ferricstore_wal_nif (ferricstore v0.3.6)

Copy Markdown View Source

Rust NIF WAL I/O module for ra_log_wal.

Replaces file:write and file:datasync with a Rust background thread that handles O_DIRECT, commit_delay batching, and fdatasync.

All NIF functions run on normal BEAM schedulers (<1μs each). The blocking I/O runs on a dedicated Rust OS thread.

This module is registered as an Erlang atom :ferricstore_wal_nif so ra_log_wal can call it as IoMod:write(Handle, Data).

Summary

Functions

Close the WAL file. Blocks until drain + sync + close.

Open a WAL file. Spawns background I/O thread.

Returns current logical file size in bytes.

Read bytes from WAL at offset. Used during recovery.

Request async fdatasync. Sends {wal_sync_complete, Ref} on completion.

Write pre-formatted iodata to the WAL buffer. Does NOT write to disk.

Functions

close(handle)

Close the WAL file. Blocks until drain + sync + close.

open(path, commit_delay_us, pre_allocate_bytes, max_buffer_bytes)

Open a WAL file. Spawns background I/O thread.

position(handle)

Returns current logical file size in bytes.

pread(handle, offset, len)

Read bytes from WAL at offset. Used during recovery.

sync(handle, caller_pid, ref)

Request async fdatasync. Sends {wal_sync_complete, Ref} on completion.

write(handle, iodata)

Write pre-formatted iodata to the WAL buffer. Does NOT write to disk.