Skip to content

[P3][adapters] Read WAL by fd/offset in node-fs instead of whole-file readFileSync #38

Description

@cevheri

Summary

node-fs adapter reads via readFileSync(path) on every read() call — whole file into memory. At open(), recovery reads entire WAL → transient 2× memory. Uses path not fd — wrong inode if path swapped mid-session (edge case).

Audit ID: Section 4 Low — Wave 3
Related: #12 compaction (large files amplify cost)

Fix direction

  • Read via fd + readSync at offset/length.
  • Optional: mmap-style single buffer cached on WalFile for session.

Acceptance criteria

  • read(offset, length) does not load entire file when length << size.
  • Tests with spy/mock or large temp file.
  • Changeset if performance observable.

Agent constraints

  • Keep sync API; match kernel WalFile contract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions