Skip to content

store: a commit costs 140–225 ms with synchronous=FULL while other programs write to the disk; NORMAL costs 0.1–0.25 ms #3382

Backlog

Description

@leemour

What

The store opens in WAL mode and leaves synchronous at its default, FULL (src/store/driver.ts, PRAGMAS). FULL syncs the WAL on every commit. Measured on the owner's NVMe/ext4 disk, 200 commits of 100 rows per run (cli-testing: commit-cost):

median per commit p90
FULL, quiet disk 3 to 5 ms 8 to 11 ms
FULL, other programs writing 140 to 225 ms 655 to 868 ms
NORMAL, either 0.1 to 0.25 ms 0.16 to 0.30 ms

A history sync commits once per page, so on a busy disk the commit alone can take several times a page's work (about 40 ms per 100 messages after #3333). Seen first while measuring tg-cli #917.

The trade-off

SQLite's docs (synchronous): WAL with NORMAL "is safe from corruption" and "always consistent", but "does lose durability": a commit made just before a power loss or an OS crash may roll back. An application crash loses nothing. NORMAL still syncs at each checkpoint (WAL).

Messages fetched from a service can be fetched again after such a loss. What is written only locally (notes, tags, contact links, approvals, run records) cannot. So the question is which writes need FULL, not only which is faster.

Options

  • Keep FULL everywhere. Nothing to do; busy disks keep paying.
  • NORMAL for the connection, FULL (or a wal_checkpoint) around the local-only writes.
  • NORMAL everywhere, documented as "the last moments before a power loss may be fetched again".

Not measured yet: an idle machine, other disks (SATA SSD, HDD, APFS, NTFS), and cli-core's real transaction shape.

🤖 Generated with Claude Code

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