Tiering: simplest split (v4 plan) #1069

Open
opened 2026-11-11 08:23:18 +00:00 by kayg · 6 comments
Owner

Intent

Keep the ADR 0062 layout: two real Home trees with the same relative folders, one on SSD and one on HDD, plus app state in .calternal/ on SSD. The trees contain ordinary files; the app presents their union. Tiering must not add work to dev's hot read, append, or list paths, or add a new cold-start database/backfill.

Approaches

  1. Extend dev's identity records (selected). Keep notes/ids.jsonl and the existing list/search indexes. Add one location bit to the existing per-file record and select the configured root when opening that path. This preserves the current lookup and listing algorithms.
  2. v3 namespace projection. A new indexed SQLite identity table, commit syncs, sidecar ordering, and cold backfill add work before the same requests. PR #970's round 8 shows the cold gate failing at 1k, 10k, and 100k; #1008's additional index work has the same risk. Drop that machinery.
  3. Filesystem caching or link tricks. Rejected by the owner decision. No special vdev, bcache, lvmcache, symlinks, or hardlinks.

Layout and request paths

The SSD and HDD roots share relative paths and folder names; each final file exists in its selected tree. The third root, .calternal/, holds current app state, including the existing IDs log, metadata indexes, history, journal, and attachment index.

Keep each existing identity record's logical path unchanged. Add an optional hdd: true bit to records whose file is on HDD; absence means SSD after the explicit offline migration. At runtime, the existing ID lookup returns the same path and the existing in-memory slot carries that bit. File open/write selects ssd_home/path or hdd_home/path with one root-prefix choice. Lists and searches continue using dev's current indexes and never merge directory scans. Existing index formats for other file owners stay in place; add the same bit only where an existing record points at a movable file. Do not create a shared current-file database.

Use the existing content/plugin classifier for placement. A one-time explicit offline migration places current files and compacts existing ID records with their bit; it is not startup work. A later tier change is queued in background through the existing file/action worker. It records intent in the existing app journal, copies to a temporary file in the destination tree, fsyncs and verifies the bytes, then atomically renames the temp file within that tree. Under the existing per-file write guard, it rechecks the source version, durably appends the new location to ids.jsonl, and only then removes and syncs the old copy. The room keeps accepting edits; if its current version changes during copy, the move retries or waits. A new location becomes visible to app readers at the durable index update. The existing history-before-file and one-second materialization rules still apply.

Cost

Operation Cost
Existing ID log load Same O(N + L) replay, where N is live files and L is log bytes; no second scan, sort, table, or backfill
ID lookup Existing expected O(1); one stored bit selects one root
List/search Existing indexed cost, e.g. O(log N + page); no two-tree join
Tier move O(B) copy and verify for a file of B bytes, plus a fixed number of journal, file, and directory syncs
Migration/rebuild One explicit offline O(F + B) pass over F files and their B bytes; never on cold request/startup

The bit is one logical bit per file. An HDD record adds about 11 JSON bytes for ,"hdd":true; 100k such records add about 1.1 MB to the log. A move needs at most one extra file-sized destination copy while it is staged; after cleanup only one final copy remains. The existing list indexes and app state add no new tables.

Failure → effect → detection → recovery → test

Failure Effect and detection Recovery Test
Crash during copy or before destination rename The committed ID record still selects the source; the existing journal identifies the temp file Resume from a verified temp or discard it; never expose it as a file Kill at each copy/fsync/rename point and replay repeatedly
Both final copies exist after a crash The last durable ID record selects the authority; compare both copies with the journal's expected version Remove only a verified stale duplicate. If versions differ, preserve both as a conflict and retry Kill after destination publish and after ID commit; verify bytes and one visible path
A tier root is missing or has the wrong install marker Startup root validation fails before serving; never fall back to the other root Restore the matching mounted root and restart Remove/swap each root and verify fail-closed behavior
Process dies while someone types during a move Existing durable history retains acknowledged edits; the per-file guard prevents retiring a newer source version Replay history, finish the pending move against the latest version, then materialize it at the selected root Type continuously, kill the test process during move, restart, and compare acknowledged text/history

What v4 drops from v3

Drop files/current.db, its SQLite writer/commit syncs, projection watermark and backfill, the separate compact ID map and its cache cap, sidecar sort indexes/counts, per-request database lookup, and request-path yields/reconciliation. Keep the ADR 0062 three-root layout, ordinary files, the existing ids.jsonl writer/lookup, current list/search indexes, and the existing crash/recovery guards.

Qualification

Use the same perf harness and fixtures as #970 at 1k, 10k, and 100k, with cold and warm paths, five ABAB rounds, and a dev-copy control in the same perf session. Every measured metric must be at or below its dev-copy bound. Also run the move-crash and kill-while-typing cases above. Stop the prototype at the first failed metric and report its exact name and cause.

## Intent Keep the ADR 0062 layout: two real Home trees with the same relative folders, one on SSD and one on HDD, plus app state in `.calternal/` on SSD. The trees contain ordinary files; the app presents their union. Tiering must not add work to dev's hot read, append, or list paths, or add a new cold-start database/backfill. ## Approaches 1. **Extend dev's identity records (selected).** Keep `notes/ids.jsonl` and the existing list/search indexes. Add one location bit to the existing per-file record and select the configured root when opening that path. This preserves the current lookup and listing algorithms. 2. **v3 namespace projection.** A new indexed SQLite identity table, commit syncs, sidecar ordering, and cold backfill add work before the same requests. PR #970's round 8 shows the cold gate failing at 1k, 10k, and 100k; #1008's additional index work has the same risk. Drop that machinery. 3. **Filesystem caching or link tricks.** Rejected by the owner decision. No special vdev, bcache, lvmcache, symlinks, or hardlinks. ## Layout and request paths The SSD and HDD roots share relative paths and folder names; each final file exists in its selected tree. The third root, `.calternal/`, holds current app state, including the existing IDs log, metadata indexes, history, journal, and attachment index. Keep each existing identity record's logical path unchanged. Add an optional `hdd: true` bit to records whose file is on HDD; absence means SSD after the explicit offline migration. At runtime, the existing ID lookup returns the same path and the existing in-memory slot carries that bit. File open/write selects `ssd_home/path` or `hdd_home/path` with one root-prefix choice. Lists and searches continue using dev's current indexes and never merge directory scans. Existing index formats for other file owners stay in place; add the same bit only where an existing record points at a movable file. Do not create a shared current-file database. Use the existing content/plugin classifier for placement. A one-time explicit offline migration places current files and compacts existing ID records with their bit; it is not startup work. A later tier change is queued in background through the existing file/action worker. It records intent in the existing app journal, copies to a temporary file in the destination tree, fsyncs and verifies the bytes, then atomically renames the temp file within that tree. Under the existing per-file write guard, it rechecks the source version, durably appends the new location to `ids.jsonl`, and only then removes and syncs the old copy. The room keeps accepting edits; if its current version changes during copy, the move retries or waits. A new location becomes visible to app readers at the durable index update. The existing history-before-file and one-second materialization rules still apply. ## Cost | Operation | Cost | |---|---| | Existing ID log load | Same `O(N + L)` replay, where `N` is live files and `L` is log bytes; no second scan, sort, table, or backfill | | ID lookup | Existing expected `O(1)`; one stored bit selects one root | | List/search | Existing indexed cost, e.g. `O(log N + page)`; no two-tree join | | Tier move | `O(B)` copy and verify for a file of `B` bytes, plus a fixed number of journal, file, and directory syncs | | Migration/rebuild | One explicit offline `O(F + B)` pass over `F` files and their `B` bytes; never on cold request/startup | The bit is one logical bit per file. An HDD record adds about 11 JSON bytes for `,"hdd":true`; 100k such records add about 1.1 MB to the log. A move needs at most one extra file-sized destination copy while it is staged; after cleanup only one final copy remains. The existing list indexes and app state add no new tables. ## Failure → effect → detection → recovery → test | Failure | Effect and detection | Recovery | Test | |---|---|---|---| | Crash during copy or before destination rename | The committed ID record still selects the source; the existing journal identifies the temp file | Resume from a verified temp or discard it; never expose it as a file | Kill at each copy/fsync/rename point and replay repeatedly | | Both final copies exist after a crash | The last durable ID record selects the authority; compare both copies with the journal's expected version | Remove only a verified stale duplicate. If versions differ, preserve both as a conflict and retry | Kill after destination publish and after ID commit; verify bytes and one visible path | | A tier root is missing or has the wrong install marker | Startup root validation fails before serving; never fall back to the other root | Restore the matching mounted root and restart | Remove/swap each root and verify fail-closed behavior | | Process dies while someone types during a move | Existing durable history retains acknowledged edits; the per-file guard prevents retiring a newer source version | Replay history, finish the pending move against the latest version, then materialize it at the selected root | Type continuously, kill the test process during move, restart, and compare acknowledged text/history | ## What v4 drops from v3 Drop `files/current.db`, its SQLite writer/commit syncs, projection watermark and backfill, the separate compact ID map and its cache cap, sidecar sort indexes/counts, per-request database lookup, and request-path yields/reconciliation. Keep the ADR 0062 three-root layout, ordinary files, the existing `ids.jsonl` writer/lookup, current list/search indexes, and the existing crash/recovery guards. ## Qualification Use the same perf harness and fixtures as #970 at 1k, 10k, and 100k, with cold and warm paths, five ABAB rounds, and a dev-copy control in the same perf session. Every measured metric must be at or below its dev-copy bound. Also run the move-crash and kill-while-typing cases above. Stop the prototype at the first failed metric and report its exact name and cause.
Author
Owner

Clarification: v4 preserves existing dev behavior, including the current startup yield in Notes::initialize_home; it adds no new yield, reconciliation, or request-path work. “Yields/reconciliation” in the v3 drop list means v3-only additions. The optional tier bit is decoded as part of the existing identity record; there is no second log pass or new cold-start database.

Clarification: v4 preserves existing dev behavior, including the current startup yield in `Notes::initialize_home`; it adds no new yield, reconciliation, or request-path work. “Yields/reconciliation” in the v3 drop list means v3-only additions. The optional tier bit is decoded as part of the existing identity record; there is no second log pass or new cold-start database.
Author
Owner

v4 prototype performance result: FAIL, stopping here

Head c933a5222a51c362bce5e3581786671f58e36a5b; comparator origin/dev 437f9ec8923b3d380506f48a77eb11493ef66fb0. Release binary SHA-256 values: dev cc0f469bdb4f40977981d018b1d535ef6e110a7e739b6da4c9694597cf66bafc, v4 a4921c2a7d85ebea40a316fdde2bdbaf0ff6df206d935ef6d0936d0d357ba177. The #970 harness SHA-256 is b36826873bb855fec4796ffe949170786f3ad8faa87f348fc0cc7f5f202ae4a2.

Method: five rounds of control A → v4 A → dev-copy control B → v4 B. Each arm used --sizes 1000,10000,100000 --runs 1 --cold-runs 1 --seed 1 --idle-secs 0 --soak-secs 0 --hot-only, through ~/bin/slot, under perf-turn tiering-v4-20261111 and both perf locks. All 20 arms exited 0. Candidate UCB is the upper 95% percentile-bootstrap bound over five paired geometric-mean ratios. The dev-copy UCB is the upper bound for control B/control A. The gate is candidate UCB ≤ dev-copy UCB. cold.notes_per_s is inverted so higher ratios mean slower throughput.

The exact #970 cold/warm Notes gate table follows. Thirteen of 30 size/metric rows fail.

Size Metric Candidate/dev median [95% CI] Dev-copy/dev UCB Gate
1k cold.first_page p50 1.005 [0.965, 1.069] 1.074 PASS
1k cold.index p50 1.003 [0.970, 1.054] 1.059 PASS
1k cold.notes_per_s p50 (inverted) 1.003 [0.970, 1.054] 1.059 PASS
1k cold.disk_written p50 0.996 [0.995, 1.000] 1.007 PASS
1k home.page_big p50 1.042 [1.002, 1.177] 1.076 FAIL
1k home.page_big p95 1.042 [1.002, 1.177] 1.076 FAIL
1k open.api_get p50 1.019 [0.983, 1.112] 1.049 FAIL
1k open.api_get p95 1.029 [0.820, 1.210] 1.130 FAIL
1k open.api_get.warm p50 1.013 [0.999, 1.098] 1.110 PASS
1k open.api_get.warm p95 1.124 [0.939, 1.272] 1.129 FAIL
10k cold.first_page p50 1.018 [0.977, 1.064] 0.988 FAIL
10k cold.index p50 1.000 [0.932, 1.043] 1.000 FAIL
10k cold.notes_per_s p50 (inverted) 1.000 [0.932, 1.043] 1.000 FAIL
10k cold.disk_written p50 0.998 [0.996, 1.001] 1.004 PASS
10k home.page_big p50 1.003 [0.920, 1.028] 1.105 PASS
10k home.page_big p95 1.016 [0.961, 1.222] 1.105 FAIL
10k open.api_get p50 0.978 [0.914, 1.009] 1.100 PASS
10k open.api_get p95 0.932 [0.774, 0.973] 1.690 PASS
10k open.api_get.warm p50 0.952 [0.882, 1.112] 1.110 FAIL
10k open.api_get.warm p95 0.939 [0.827, 1.167] 1.253 PASS
100k cold.first_page p50 0.997 [0.812, 1.080] 1.710 PASS
100k cold.index p50 1.023 [0.883, 1.043] 1.498 PASS
100k cold.notes_per_s p50 (inverted) 1.023 [0.883, 1.043] 1.498 PASS
100k cold.disk_written p50 1.000 [1.000, 1.006] 1.000 FAIL
100k home.page_big p50 0.988 [0.980, 1.043] 1.198 PASS
100k home.page_big p95 1.014 [0.836, 1.086] 1.526 PASS
100k open.api_get p50 0.944 [0.734, 1.113] 1.055 FAIL
100k open.api_get p95 0.802 [0.380, 1.021] 1.731 PASS
100k open.api_get.warm p50 1.010 [0.887, 1.102] 1.019 FAIL
100k open.api_get.warm p95 0.968 [0.688, 0.969] 1.078 PASS

Failure causes and scope

  • At 10k, cold.first_page is 1.064 UCB vs 0.988 control UCB; cold.index and inverted cold.notes_per_s are 1.043 vs 1.000. In crates/notes/src/index.rs, put_with now calls tier_of(id) before put_with_tier; that adds a hash lookup for each path update during cold identity updates and is consistent with the cold slowdown.
  • Warm failures are exact gate failures because the candidate UCB exceeds the dev-copy UCB. The read path does not invoke the move primitive. It now carries a tier field in the in-memory Slot; this run does not distinguish a slot-layout/cache effect from run variation, so the measured upper-bound excess is the supported cause.
  • At 100k, cold.disk_written UCB is 1.006 vs a 1.000 dev-copy bound. SSD rows omit hdd:false during serialization, so this run does not attribute the small write delta to longer identity records. The gate still fails.

The prototype is not an end-to-end split-root implementation: the move primitive is not wired into Home reads/writes, and Notes still uses one notes_dir. This run measured the identity-record change with the harness's single-root mode; it does not qualify SSD/HDD root selection or tiered moves.

Correctness checks passed before measurement: cargo fmt --all -- --check; cargo test -j4 -p calternal-notes (579 passed, 0 failed, 6 ignored); tier_move::tests::killed_tier_move_retries_from_copy_or_both_copies; storage_crash::kill9_after_ack_during_split_hdd_save_recovers_exact_text.

## v4 prototype performance result: FAIL, stopping here Head `c933a5222a51c362bce5e3581786671f58e36a5b`; comparator `origin/dev` `437f9ec8923b3d380506f48a77eb11493ef66fb0`. Release binary SHA-256 values: dev `cc0f469bdb4f40977981d018b1d535ef6e110a7e739b6da4c9694597cf66bafc`, v4 `a4921c2a7d85ebea40a316fdde2bdbaf0ff6df206d935ef6d0936d0d357ba177`. The #970 harness SHA-256 is `b36826873bb855fec4796ffe949170786f3ad8faa87f348fc0cc7f5f202ae4a2`. Method: five rounds of control A → v4 A → dev-copy control B → v4 B. Each arm used `--sizes 1000,10000,100000 --runs 1 --cold-runs 1 --seed 1 --idle-secs 0 --soak-secs 0 --hot-only`, through `~/bin/slot`, under `perf-turn tiering-v4-20261111` and both perf locks. All 20 arms exited 0. Candidate UCB is the upper 95% percentile-bootstrap bound over five paired geometric-mean ratios. The dev-copy UCB is the upper bound for control B/control A. The gate is candidate UCB ≤ dev-copy UCB. `cold.notes_per_s` is inverted so higher ratios mean slower throughput. The exact #970 cold/warm Notes gate table follows. Thirteen of 30 size/metric rows fail. | Size | Metric | Candidate/dev median [95% CI] | Dev-copy/dev UCB | Gate | |---:|---|---:|---:|:---:| | 1k | cold.first_page p50 | 1.005 [0.965, 1.069] | 1.074 | PASS | | 1k | cold.index p50 | 1.003 [0.970, 1.054] | 1.059 | PASS | | 1k | cold.notes_per_s p50 (inverted) | 1.003 [0.970, 1.054] | 1.059 | PASS | | 1k | cold.disk_written p50 | 0.996 [0.995, 1.000] | 1.007 | PASS | | 1k | home.page_big p50 | 1.042 [1.002, 1.177] | 1.076 | FAIL | | 1k | home.page_big p95 | 1.042 [1.002, 1.177] | 1.076 | FAIL | | 1k | open.api_get p50 | 1.019 [0.983, 1.112] | 1.049 | FAIL | | 1k | open.api_get p95 | 1.029 [0.820, 1.210] | 1.130 | FAIL | | 1k | open.api_get.warm p50 | 1.013 [0.999, 1.098] | 1.110 | PASS | | 1k | open.api_get.warm p95 | 1.124 [0.939, 1.272] | 1.129 | FAIL | | 10k | cold.first_page p50 | 1.018 [0.977, 1.064] | 0.988 | FAIL | | 10k | cold.index p50 | 1.000 [0.932, 1.043] | 1.000 | FAIL | | 10k | cold.notes_per_s p50 (inverted) | 1.000 [0.932, 1.043] | 1.000 | FAIL | | 10k | cold.disk_written p50 | 0.998 [0.996, 1.001] | 1.004 | PASS | | 10k | home.page_big p50 | 1.003 [0.920, 1.028] | 1.105 | PASS | | 10k | home.page_big p95 | 1.016 [0.961, 1.222] | 1.105 | FAIL | | 10k | open.api_get p50 | 0.978 [0.914, 1.009] | 1.100 | PASS | | 10k | open.api_get p95 | 0.932 [0.774, 0.973] | 1.690 | PASS | | 10k | open.api_get.warm p50 | 0.952 [0.882, 1.112] | 1.110 | FAIL | | 10k | open.api_get.warm p95 | 0.939 [0.827, 1.167] | 1.253 | PASS | | 100k | cold.first_page p50 | 0.997 [0.812, 1.080] | 1.710 | PASS | | 100k | cold.index p50 | 1.023 [0.883, 1.043] | 1.498 | PASS | | 100k | cold.notes_per_s p50 (inverted) | 1.023 [0.883, 1.043] | 1.498 | PASS | | 100k | cold.disk_written p50 | 1.000 [1.000, 1.006] | 1.000 | FAIL | | 100k | home.page_big p50 | 0.988 [0.980, 1.043] | 1.198 | PASS | | 100k | home.page_big p95 | 1.014 [0.836, 1.086] | 1.526 | PASS | | 100k | open.api_get p50 | 0.944 [0.734, 1.113] | 1.055 | FAIL | | 100k | open.api_get p95 | 0.802 [0.380, 1.021] | 1.731 | PASS | | 100k | open.api_get.warm p50 | 1.010 [0.887, 1.102] | 1.019 | FAIL | | 100k | open.api_get.warm p95 | 0.968 [0.688, 0.969] | 1.078 | PASS | ### Failure causes and scope - At 10k, `cold.first_page` is 1.064 UCB vs 0.988 control UCB; `cold.index` and inverted `cold.notes_per_s` are 1.043 vs 1.000. In `crates/notes/src/index.rs`, `put_with` now calls `tier_of(id)` before `put_with_tier`; that adds a hash lookup for each path update during cold identity updates and is consistent with the cold slowdown. - Warm failures are exact gate failures because the candidate UCB exceeds the dev-copy UCB. The read path does not invoke the move primitive. It now carries a tier field in the in-memory `Slot`; this run does not distinguish a slot-layout/cache effect from run variation, so the measured upper-bound excess is the supported cause. - At 100k, `cold.disk_written` UCB is 1.006 vs a 1.000 dev-copy bound. SSD rows omit `hdd:false` during serialization, so this run does not attribute the small write delta to longer identity records. The gate still fails. The prototype is not an end-to-end split-root implementation: the move primitive is not wired into Home reads/writes, and Notes still uses one `notes_dir`. This run measured the identity-record change with the harness's single-root mode; it does not qualify SSD/HDD root selection or tiered moves. Correctness checks passed before measurement: `cargo fmt --all -- --check`; `cargo test -j4 -p calternal-notes` (579 passed, 0 failed, 6 ignored); `tier_move::tests::killed_tier_move_retries_from_copy_or_both_copies`; `storage_crash::kill9_after_ack_during_split_hdd_save_recovers_exact_text`.
Author
Owner

Scope overlap: PR #1010 tracks adjacent dev-native Home identity and root-validation work. This v4 prototype stays limited to the Notes identity tier bit and crash-safe move primitive; it does not modify #1010.

Scope overlap: PR #1010 tracks adjacent dev-native Home identity and root-validation work. This v4 prototype stays limited to the Notes identity tier bit and crash-safe move primitive; it does not modify #1010.
Author
Owner

v5 — split roots, no tier metadata

This supersedes v4. Each file has one relative path under ssd_root (today's Notes/Home) and its mirror under optional hdd_root. There is no tier field in the index, Slot, notes records, or per-row state. App state stays on SSD.

Reads open SSD first and try HDD only on ENOENT. If both opens miss, retry SSD once to close a move/write ENOENT race, then return not found. Writes publish durably to SSD; duplicate HDD cleanup runs in background after SSD durability, with startup cleanup retrying any duplicate. The mover is background-only and rate-limited: copy to an HDD-side .tmp, fsync it, rename within HDD, fsync that directory, then unlink SSD and fsync its directory. Listing and watching cover the union; SSD wins duplicates. A single hdd_nonempty flag skips the HDD walk when empty. With hdd_root unset, dispatch stays on dev's existing code path.

Operation / size Cost
Resident metadata O(1) roots + one bool; 0 bytes per file and no index changes
SSD read/save Same path as dev; no HDD probe, index lookup, or walk on the request path
HDD read One failed SSD open plus one HDD open: O(1)
Union discovery SSD-only when HDD is empty; otherwise O(S+H) background scan, SSD wins by relative path
Move one file of B bytes O(B) copy, at most B extra temp bytes, fixed fsync/rename/unlink steps
Crash/failure point Recovery and test
Write temp partial or temp fsync fails Existing SSD/HDD source remains authoritative; ignore/remove temp and retry
Write rename to SSD or SSD-dir fsync HDD source remains; after restart read the durable SSD name if present, otherwise HDD; retry
Write unlinks HDD or HDD-dir fsync fails Durable SSD wins if both remain; startup removes duplicate; retry cleanup
Move copy partial or temp fsync fails SSD remains authoritative; discard temp or resume copy
Move HDD rename or HDD-dir fsync Keep SSD until HDD final is durable; before dir sync recopy, after sync both may exist and SSD wins
Move unlinks SSD or SSD-dir fsync fails HDD is already durable; after restart SSD wins if still present, otherwise HDD; retry idempotently
SSD ENOENT then HDD ENOENT Retry SSD once for a concurrent publish; return not found only if it also misses. Test move/write races
Cross-filesystem rename returns EXDEV Never rename SSD to HDD; source stays intact and mover retries by copy. Test EXDEV

Gates: crash-test each write/move boundary plus ENOENT/EXDEV; unit-test union, precedence, cleanup, and single-root behavior. On perf VMs, run five ABAB rounds with dev-copy controls at 1k/10k/100k for cold first_page/index, home.page_big, open.api_get, warm open, save p50/p95/p99, and disk_written. Run both single-root and split with 0% HDD; candidate bounds must stay within dev-copy bounds. If control spread exceeds ~5%, add rounds until it tightens. Report only for 80% HDD: cold HDD open and mover cost while saving. Build/test on dev-01 through Nix/slot; measure only through perf-turn (each turn ≤90 min). No PR unless every gate passes.

## v5 — split roots, no tier metadata This supersedes v4. Each file has one relative path under `ssd_root` (today's Notes/Home) and its mirror under optional `hdd_root`. There is no tier field in the index, Slot, notes records, or per-row state. App state stays on SSD. Reads open SSD first and try HDD only on ENOENT. If both opens miss, retry SSD once to close a move/write ENOENT race, then return not found. Writes publish durably to SSD; duplicate HDD cleanup runs in background after SSD durability, with startup cleanup retrying any duplicate. The mover is background-only and rate-limited: copy to an HDD-side `.tmp`, fsync it, rename within HDD, fsync that directory, then unlink SSD and fsync its directory. Listing and watching cover the union; SSD wins duplicates. A single `hdd_nonempty` flag skips the HDD walk when empty. With `hdd_root` unset, dispatch stays on dev's existing code path. | Operation / size | Cost | |---|---| | Resident metadata | O(1) roots + one bool; 0 bytes per file and no index changes | | SSD read/save | Same path as dev; no HDD probe, index lookup, or walk on the request path | | HDD read | One failed SSD open plus one HDD open: O(1) | | Union discovery | SSD-only when HDD is empty; otherwise O(S+H) background scan, SSD wins by relative path | | Move one file of B bytes | O(B) copy, at most B extra temp bytes, fixed fsync/rename/unlink steps | | Crash/failure point | Recovery and test | |---|---| | Write temp partial or temp fsync fails | Existing SSD/HDD source remains authoritative; ignore/remove temp and retry | | Write rename to SSD or SSD-dir fsync | HDD source remains; after restart read the durable SSD name if present, otherwise HDD; retry | | Write unlinks HDD or HDD-dir fsync fails | Durable SSD wins if both remain; startup removes duplicate; retry cleanup | | Move copy partial or temp fsync fails | SSD remains authoritative; discard temp or resume copy | | Move HDD rename or HDD-dir fsync | Keep SSD until HDD final is durable; before dir sync recopy, after sync both may exist and SSD wins | | Move unlinks SSD or SSD-dir fsync fails | HDD is already durable; after restart SSD wins if still present, otherwise HDD; retry idempotently | | SSD ENOENT then HDD ENOENT | Retry SSD once for a concurrent publish; return not found only if it also misses. Test move/write races | | Cross-filesystem rename returns EXDEV | Never rename SSD to HDD; source stays intact and mover retries by copy. Test EXDEV | Gates: crash-test each write/move boundary plus ENOENT/EXDEV; unit-test union, precedence, cleanup, and single-root behavior. On perf VMs, run five ABAB rounds with dev-copy controls at 1k/10k/100k for cold first_page/index, home.page_big, open.api_get, warm open, save p50/p95/p99, and disk_written. Run both single-root and split with 0% HDD; candidate bounds must stay within dev-copy bounds. If control spread exceeds ~5%, add rounds until it tightens. Report only for 80% HDD: cold HDD open and mover cost while saving. Build/test on dev-01 through Nix/slot; measure only through perf-turn (each turn ≤90 min). No PR unless every gate passes.
Author
Owner

v5 implementation scope

PR #1010 is open and also touches Notes Home/scan/watcher roots. This branch stays based on the requested origin/dev head and does not pull in its unmerged Files identity/index layer; the v5 gate requires the existing Notes index to remain byte-for-byte unchanged. I will keep v5 limited to Notes root I/O, union discovery, and the background move/duplicate cleanup path. This leaves possible merge conflicts in shared Notes files if #1010 lands first; I will not edit that branch.

Planned boundaries: a new Notes split-root helper owns SSD-first reads, safe relative paths, copy/fsync/publish/unlink, and crash hooks; Home/Notes carries only the optional HDD root and one non-empty flag; scan/watch/meta call the helper for union behavior; the server exposes the optional root for the prototype; tests cover every durable boundary and single-root dispatch. Then remote correctness gates, the requested perf matrix, and a PR only if every gate passes.

## v5 implementation scope PR #1010 is open and also touches Notes Home/scan/watcher roots. This branch stays based on the requested `origin/dev` head and does not pull in its unmerged Files identity/index layer; the v5 gate requires the existing Notes index to remain byte-for-byte unchanged. I will keep v5 limited to Notes root I/O, union discovery, and the background move/duplicate cleanup path. This leaves possible merge conflicts in shared Notes files if #1010 lands first; I will not edit that branch. Planned boundaries: a new Notes split-root helper owns SSD-first reads, safe relative paths, copy/fsync/publish/unlink, and crash hooks; Home/Notes carries only the optional HDD root and one non-empty flag; scan/watch/meta call the helper for union behavior; the server exposes the optional root for the prototype; tests cover every durable boundary and single-root dispatch. Then remote correctness gates, the requested perf matrix, and a PR only if every gate passes.
Author
Owner

v5 recovery status

  • Head: 72b600edefa154a7e4f611fb884545fdc802177a on pushed feat/tiering-v5, based on origin/dev be968d9df0c759d4200c50d8d8396990cd43338f.
  • Done: split-root prototype, crash/unit coverage, formatting, Clippy, Notes tests (663 passed, 6 ignored), workspace tests, and clean post-reboot release builds for dev, v5, and calternal-perf.
  • Left: all perf gate rows for single-root and split0 (1k/10k/100k: cold first_page/index/throughput, page_big p50/p95, cold and warm API open p50/p95, durable save p50/p95/p99, disk_written), with extra rounds if dev-copy control width exceeds 5%; plus the report-only 80% HDD cold-open and mover/save measurements.
  • No perf rounds were started and no PR is open; this work is paused for the Notes layout priority.
## v5 recovery status - Head: `72b600edefa154a7e4f611fb884545fdc802177a` on pushed `feat/tiering-v5`, based on `origin/dev` `be968d9df0c759d4200c50d8d8396990cd43338f`. - Done: split-root prototype, crash/unit coverage, formatting, Clippy, Notes tests (663 passed, 6 ignored), workspace tests, and clean post-reboot release builds for dev, v5, and `calternal-perf`. - Left: all perf gate rows for single-root and split0 (1k/10k/100k: cold first_page/index/throughput, page_big p50/p95, cold and warm API open p50/p95, durable save p50/p95/p99, disk_written), with extra rounds if dev-copy control width exceeds 5%; plus the report-only 80% HDD cold-open and mover/save measurements. - No perf rounds were started and no PR is open; this work is paused for the Notes layout priority.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#1069
No description provided.