Rename a tag across every note (bulk-edit job) #101

Closed
opened 2026-10-14 03:04:52 +00:00 by kayg · 3 comments
Owner

Renaming a tag rewrites every #tag (and nested #tag/child) in all notes through the #9 bulk-edit job: journaled, resumable, undo as one step, never touching code blocks, inline code or URLs. UI: rename from the tag's context menu in the sidebar, with a count preview and a toast with Undo. Perf: 10k notes with the tag must finish under the budget and never block typing (V4). Tests: unit (edge cases: #tag inside words, code, links, headings), job resume after kill -9, and e2e.

Renaming a tag rewrites every `#tag` (and nested `#tag/child`) in all notes through the #9 bulk-edit job: journaled, resumable, undo as one step, never touching code blocks, inline code or URLs. UI: rename from the tag's context menu in the sidebar, with a count preview and a toast with Undo. Perf: 10k notes with the tag must finish under the budget and never block typing (V4). Tests: unit (edge cases: `#tag` inside words, code, links, headings), job resume after kill -9, and e2e.
Author
Owner

Perf: tag rename on the 10k and 100k fixture Homes while a client types (PR #201)

Bench: crates/notes/examples/tag_bench.rs, a release build run on a fresh copy of calternal-perf-work-44/fixtures/n{10000,100000}-s1. It times the count preview, then renames a tag in every note that has it while another note is typed into (one character every 5 ms through the room, timing each round trip until the change is durable in history), then runs Undo the same way. Like the web app, it polls notes.job every 500 ms.

Read these with the machine in mind. This is the shared dev box, not the quiet perf machine: load average was 40 to 110 on 12 cores the whole time (about 8 agents building and running e2e at once). A single-write history commit with nothing else in it took 150 to 900 ms at the worst moments. The same bench gives different numbers from one run to the next. Treat the absolute values as an upper bound and compare idle typing with typing during the job, measured minutes apart.

10k Home: #learning is in 2,034 notes

run (load) job, plan + apply typing idle p50 / p95 / max typing during rename p50 / p95 / max undo typing during undo p50 / p95
A (≈100, quieter moment) 5.9 s 8.2 / 12.2 / 21 ms 25.6 / 72.1 / 102 ms 5.3 s 39 / 93 ms
B (≈30) 6.6 s 8.3 / 14.3 / 39 ms 20.4 / 80.0 / 141 ms 5.0 s 32 / 105 ms
final code, 3 runs (90 to 110) 30 to 69 s 18 to 30 / 66 to 161 ms 104 to 152 / 293 to 593 ms 15 to 47 s 95 to 204 / 340 to 953 ms
  • Preview (count): 1.1 to 1.6 ms. The very first call right after a cold start waits on the note list catching up, 1 to 5 s.
  • Peak memory for the whole run: 183 to 206 MB.
  • For comparison, the existing link-rename job (#9, rename_bench with 10k notes and 2,000 linking to one hub, same load period as run A) gave rename 8.6 s, typing p50 31.8 / p95 106.8 / max 227 ms with idle p50 11.9. The tag rename is in the same range as the job machinery that's already merged.
  • In-process test a_big_tag_rename_never_stalls_typing (600 notes, debug build) passes with the worst keystroke round trip at 12 ms while the job runs (112 keystrokes typed during it).

100k Home: #learning / #reading / #family, each in about 20,700 notes

plan apply typing during rename p50 / p95 / max undo typing during undo p50 / p95 / max
before the bulk fixes in this PR (load ≈55) 55 s 255 s 111 / 407 / 1,363 ms 353 s 324 / 981 / 5,510 ms
after (load ≈100) 23 s 134 s 69 / 232 / 488 ms 140 s 114 / 263 / 1,151 ms

Idle typing during the "after" run: p50 13 / p95 31 / max 228 ms.

What made the difference, found with samply on the 100k run:

  1. Every batch rewrote the whole plan (several MB of JSON for 20k steps) through the history writer that typing also uses. Each batch now writes only its own results to job_steps.
  2. Every notes.job poll read and parsed that whole plan. A running job's report now comes from memory.
  3. Planning opened one room per note and kept them all; peak memory reached 1.35 GB at 100k. Rooms opened only for reading now close as soon as they've been read (Cmd::Rest).

Tried and dropped, both measured with A/B runs:

  • Saving each note's file as part of its step, to limit concurrent fsyncs: 5× slower jobs, typing no better.
  • A background WAL checkpointer for history: no gain.
  • Smaller job concurrency (8 or 4 in flight instead of 32): much slower, with no clear gain for typing.

What remains is disk contention. During the job, typing's history fsync shares the disk with the job's file saves. On this box a lone commit already takes hundreds of ms at peak, which explains the tails above. The perf machine should give the honest numbers. There's no tag-rename budget in perf/budgets.json yet; I'd suggest about 10 s for 2k notes and about 3 min for 20k notes on the perf machine, with typing p95 under 2× idle.

Follow-ups I'd file:

  • (a) Steady-state memory while applying: rooms the job edited stay open for the 60 s idle time after their save.
  • (b) notes.job lists every note id, which for 20k notes is about 720 KB per poll.
  • (c) Rooms read history through a fresh SQLite connection on every open (shows up in the profile).
## Perf: tag rename on the 10k and 100k fixture Homes while a client types (PR #201) Bench: `crates/notes/examples/tag_bench.rs`, a release build run on a fresh copy of `calternal-perf-work-44/fixtures/n{10000,100000}-s1`. It times the count preview, then renames a tag in every note that has it while another note is typed into (one character every 5 ms through the room, timing each round trip until the change is durable in history), then runs Undo the same way. Like the web app, it polls `notes.job` every 500 ms. **Read these with the machine in mind.** This is the shared dev box, not the quiet perf machine: load average was 40 to 110 on 12 cores the whole time (about 8 agents building and running e2e at once). A single-write history commit with nothing else in it took 150 to 900 ms at the worst moments. The same bench gives different numbers from one run to the next. Treat the absolute values as an upper bound and compare idle typing with typing during the job, measured minutes apart. ### 10k Home: #learning is in 2,034 notes | run (load) | job, plan + apply | typing idle p50 / p95 / max | typing during rename p50 / p95 / max | undo | typing during undo p50 / p95 | |---|---|---|---|---|---| | A (≈100, quieter moment) | 5.9 s | 8.2 / 12.2 / 21 ms | 25.6 / 72.1 / 102 ms | 5.3 s | 39 / 93 ms | | B (≈30) | 6.6 s | 8.3 / 14.3 / 39 ms | 20.4 / 80.0 / 141 ms | 5.0 s | 32 / 105 ms | | final code, 3 runs (90 to 110) | 30 to 69 s | 18 to 30 / 66 to 161 ms | 104 to 152 / 293 to 593 ms | 15 to 47 s | 95 to 204 / 340 to 953 ms | - Preview (count): 1.1 to 1.6 ms. The very first call right after a cold start waits on the note list catching up, 1 to 5 s. - Peak memory for the whole run: 183 to 206 MB. - For comparison, the **existing** link-rename job (#9, `rename_bench` with 10k notes and 2,000 linking to one hub, same load period as run A) gave rename 8.6 s, typing p50 31.8 / p95 106.8 / max 227 ms with idle p50 11.9. The tag rename is in the same range as the job machinery that's already merged. - In-process test `a_big_tag_rename_never_stalls_typing` (600 notes, debug build) passes with the worst keystroke round trip at **12 ms** while the job runs (112 keystrokes typed during it). ### 100k Home: #learning / #reading / #family, each in about 20,700 notes | | plan | apply | typing during rename p50 / p95 / max | undo | typing during undo p50 / p95 / max | |---|---|---|---|---|---| | before the bulk fixes in this PR (load ≈55) | 55 s | 255 s | 111 / 407 / 1,363 ms | 353 s | 324 / 981 / 5,510 ms | | after (load ≈100) | 23 s | 134 s | **69 / 232 / 488 ms** | 140 s | 114 / 263 / 1,151 ms | Idle typing during the "after" run: p50 13 / p95 31 / max 228 ms. What made the difference, found with samply on the 100k run: 1. Every batch rewrote the whole plan (several MB of JSON for 20k steps) through the history writer that typing also uses. Each batch now writes only its own results to `job_steps`. 2. Every `notes.job` poll read and parsed that whole plan. A running job's report now comes from memory. 3. Planning opened one room per note and kept them all; peak memory reached 1.35 GB at 100k. Rooms opened only for reading now close as soon as they've been read (`Cmd::Rest`). Tried and dropped, both measured with A/B runs: - Saving each note's file as part of its step, to limit concurrent fsyncs: 5× slower jobs, typing no better. - A background WAL checkpointer for history: no gain. - Smaller job concurrency (8 or 4 in flight instead of 32): much slower, with no clear gain for typing. What remains is disk contention. During the job, typing's history fsync shares the disk with the job's file saves. On this box a lone commit already takes hundreds of ms at peak, which explains the tails above. The perf machine should give the honest numbers. There's no tag-rename budget in perf/budgets.json yet; I'd suggest about 10 s for 2k notes and about 3 min for 20k notes on the perf machine, with typing p95 under 2× idle. Follow-ups I'd file: - (a) Steady-state memory while applying: rooms the job edited stay open for the 60 s idle time after their save. - (b) `notes.job` lists every note id, which for 20k notes is about 720 KB per poll. - (c) Rooms read history through a fresh SQLite connection on every open (shows up in the profile).
Author
Owner

Screenshots (real server and engine, e2e harness). Each pair: the rename field with its N-notes count, then the moment after Enter (the toast grows in from a dot; some shots catch it mid-spring; this box ran at load 80-110, which slows the motion). Final UI on PR #216.

chromium 390 light

chromium-390-light-1-field.png chromium-390-light-2-toast.png

chromium 900 light

chromium-900-light-1-field.png chromium-900-light-2-toast.png

chromium 1440 light

chromium-1440-light-1-field.png chromium-1440-light-2-toast.png

chromium 390 dark

chromium-390-dark-1-field.png chromium-390-dark-2-toast.png

chromium 900 dark

chromium-900-dark-1-field.png chromium-900-dark-2-toast.png

chromium 1440 dark

chromium-1440-dark-1-field.png chromium-1440-dark-2-toast.png

webkit 390 light

webkit-390-light-1-field.png webkit-390-light-2-toast.png

webkit 900 light

webkit-900-light-1-field.png webkit-900-light-2-toast.png

webkit 1440 light

webkit-1440-light-1-field.png webkit-1440-light-2-toast.png

webkit 390 dark

webkit-390-dark-1-field.png webkit-390-dark-2-toast.png

webkit 900 dark

webkit-900-dark-1-field.png webkit-900-dark-2-toast.png

webkit 1440 dark

webkit-1440-dark-1-field.png webkit-1440-dark-2-toast.png

Screenshots (real server and engine, e2e harness). Each pair: the rename field with its N-notes count, then the moment after Enter (the toast grows in from a dot; some shots catch it mid-spring; this box ran at load 80-110, which slows the motion). Final UI on PR #216. **chromium 390 light** ![chromium-390-light-1-field.png](https://git.kayg.org/attachments/71bd0b80-c7f0-4445-a687-8cc255f88555) ![chromium-390-light-2-toast.png](https://git.kayg.org/attachments/7807d46a-bb11-45ff-a8b1-53869bbdd37d) **chromium 900 light** ![chromium-900-light-1-field.png](https://git.kayg.org/attachments/aee86500-a4e7-42f7-aab3-9ce235283ade) ![chromium-900-light-2-toast.png](https://git.kayg.org/attachments/e59bbce5-6141-486f-b63f-7360f5f5b4b1) **chromium 1440 light** ![chromium-1440-light-1-field.png](https://git.kayg.org/attachments/8f2737d4-0d7f-4bd1-bf5a-212c29042a2a) ![chromium-1440-light-2-toast.png](https://git.kayg.org/attachments/c6c5be33-eaaf-41ff-84e5-d4b312c9e7c2) **chromium 390 dark** ![chromium-390-dark-1-field.png](https://git.kayg.org/attachments/aeb5efff-fa3d-4ad9-8de3-f655775f130e) ![chromium-390-dark-2-toast.png](https://git.kayg.org/attachments/3ddcc4e8-bb0f-49bc-b320-16cf81edcad3) **chromium 900 dark** ![chromium-900-dark-1-field.png](https://git.kayg.org/attachments/a24e51f3-d232-40c9-828c-3324a9e3b566) ![chromium-900-dark-2-toast.png](https://git.kayg.org/attachments/800c7846-e83f-4717-8c50-d38681c099bf) **chromium 1440 dark** ![chromium-1440-dark-1-field.png](https://git.kayg.org/attachments/e18701bf-e963-425a-86a3-43eb6491e7e6) ![chromium-1440-dark-2-toast.png](https://git.kayg.org/attachments/3caa66ec-36eb-450e-95ab-19946c42c765) **webkit 390 light** ![webkit-390-light-1-field.png](https://git.kayg.org/attachments/673fd86f-0515-48ac-94cc-ac0561e04fbe) ![webkit-390-light-2-toast.png](https://git.kayg.org/attachments/c7dca1e4-230d-4c3d-b82a-5eac90150e07) **webkit 900 light** ![webkit-900-light-1-field.png](https://git.kayg.org/attachments/1f8818b0-c903-4345-895c-8dd0d7130f47) ![webkit-900-light-2-toast.png](https://git.kayg.org/attachments/9a6deba7-38d7-42f9-865c-79cecc3a82a5) **webkit 1440 light** ![webkit-1440-light-1-field.png](https://git.kayg.org/attachments/187eddf2-9e10-489d-b8ea-e47f5e6c20a5) ![webkit-1440-light-2-toast.png](https://git.kayg.org/attachments/012600c0-4e06-48a1-a33d-78a2d1383dbc) **webkit 390 dark** ![webkit-390-dark-1-field.png](https://git.kayg.org/attachments/bd8bd588-514d-45e2-8f6a-73d665acb9be) ![webkit-390-dark-2-toast.png](https://git.kayg.org/attachments/f8b6b28e-d7ba-4c47-aa17-c2c5687308aa) **webkit 900 dark** ![webkit-900-dark-1-field.png](https://git.kayg.org/attachments/78136ea6-fca9-497e-b3a4-6aa5f2664fba) ![webkit-900-dark-2-toast.png](https://git.kayg.org/attachments/510690ab-ad94-4bc2-bbb5-316267fac4b6) **webkit 1440 dark** ![webkit-1440-dark-1-field.png](https://git.kayg.org/attachments/b14afe55-0f63-4aa4-9e26-245f94096608) ![webkit-1440-dark-2-toast.png](https://git.kayg.org/attachments/b90af2a7-7755-4d71-a8c1-19a38906200b)
Author
Owner

Drag-to-merge (PR #238), 1440, Chromium and WebKit, light and dark: the dragged tag held over the other tag (that row lights up), the bar asking "Merge #a into #b? N notes", and the result. One note had both tags and keeps the tag once. The 390 runs timed out on this overloaded box (load ≈100), so there are no phone shots. Some frames catch the bar mid-morph. These tests share one server, so the sidebar also shows tags from the other tests.

chromium 1440 light

1-drag 2-ask 3-done

chromium 1440 dark

1-drag 2-ask 3-done

webkit 1440 light

1-drag 2-ask 3-done

webkit 1440 dark

1-drag 2-ask 3-done

Drag-to-merge (PR #238), 1440, Chromium and WebKit, light and dark: the dragged tag held over the other tag (that row lights up), the bar asking "Merge #a into #b? N notes", and the result. One note had both tags and keeps the tag once. The 390 runs timed out on this overloaded box (load ≈100), so there are no phone shots. Some frames catch the bar mid-morph. These tests share one server, so the sidebar also shows tags from the other tests. **chromium 1440 light** ![1-drag](https://git.kayg.org/attachments/61cf64f5-d6d9-4b09-9c36-ea0b8eb632fd) ![2-ask](https://git.kayg.org/attachments/7abcf091-c860-46c3-bb35-67071778fae7) ![3-done](https://git.kayg.org/attachments/36b23953-fac0-4fb0-bc5a-76a73f245fbf) **chromium 1440 dark** ![1-drag](https://git.kayg.org/attachments/aa16341e-6368-4991-b572-96ce6dced7ee) ![2-ask](https://git.kayg.org/attachments/aad94d14-5ccc-4024-8d10-1ea5bda7c0c7) ![3-done](https://git.kayg.org/attachments/3d564354-322f-490c-90d5-6cd53dae1042) **webkit 1440 light** ![1-drag](https://git.kayg.org/attachments/9a6dcba7-4cc4-4420-809e-26fb81acecbf) ![2-ask](https://git.kayg.org/attachments/7fbd9a7a-67b8-48fe-9fdb-592077832cc5) ![3-done](https://git.kayg.org/attachments/7d3072a1-e301-41a6-9b8b-34530b8d3695) **webkit 1440 dark** ![1-drag](https://git.kayg.org/attachments/50408c9a-bb20-44c3-89e9-015894a73d5c) ![2-ask](https://git.kayg.org/attachments/4b8eceab-a5c8-40f0-ac07-ef140666693f) ![3-done](https://git.kayg.org/attachments/4a40e5df-54bd-497b-9ce2-e588a6126675)
kayg closed this issue 2026-10-14 11:20:06 +00:00
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#101
No description provided.