Skip to content

perf: pickup-no-flush - #857

Merged
fizzy-pm[bot] merged 2 commits into
mainfrom
perf/pickup-no-flush
Oct 26, 2026
Merged

fizzy-pm[bot] merged 2 commits into
mainfrom
perf/pickup-no-flush

Conversation

@fizzy-linux

@fizzy-linux fizzy-linux Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of fizzyedit/work#388

Goal

Reopening a document must never hitch: Tracks.pickUp (run from tick on the UI thread) no longer packs or writes on the frame, and still restores the history in every case.

What changed and why

pickUp reads the newest waiting KeptFile for the document's file straight from pending (version 1 bytes, which track_file.read accepts) instead of calling flushPending. flushPending remains only for quitting. Review F1: a track the checkpoint's thread had already taken (takeChanged) is in neither pending nor on disk until its rename, so a reopen then lost or truncated the history. When the file is not in pending, pickUp now waits for writing to drain before the disk read: rare, so the common reopen stays off the writer.

How it was verified

Test "reopening a document reads its closed track from memory and writes nothing" fails without the change (expected 1, found 0). New test "reopening a document while the checkpoint's thread writes its track keeps the history" (takeChanged, reopen before the thread's rename) fails without the wait (expected 1, found 0) and passes with it. Both run in test-integration (94/94 steps, 427/427 tests); zb build test 181/181; check-fmt clean. Reopen frame, 12.35 MB pending track, ReleaseFast, Ryzen 7 8745HS, Linux: median 32.8 ms on main, 5.3 ms here (the common path is unchanged by the wait; it only runs when the checkpoint thread holds the track). No window launched.

Not done / follow-ups

The remaining ~5 ms is track_file.read of a 12 MB track on the frame; moving that read off the frame is a separate step. A reopen during an in-flight checkpoint write blocks the frame for that write.

Changes (31 files, +3140/-3615)
 .github/workflows/ci.yml                           |    1 -
 app/Tracks.zig                                     |   63 +-
 app/store/PluginLoader_web.zig                     |    4 +-
 app/store/PluginStore.zig                          |    2 +-
 build.zig.zon                                      |    6 -
 build/app.zig                                      |    3 +-
 build/web.zig                                      |   83 +-
 core/AGENTS.md                                     |    3 +-
 core/widgets/ScrollArea.zig                        |   44 +-
 docs/DEPENDENCIES.md                               |   41 +-
 plugins/markdown/src/md/net_image.zig              |    4 +-
 readme.md                                          |   15 +-
 scripts/compile-shaders.sh                         |    3 +-
 sdk/plugin_sdk.zig                                 |    2 +-
 src/backend/backend_web.zig                        |    8 +-
 src/editor/Editor.zig                              |    2 +-
 src/editor/Keybinds.zig                            |    2 +-
 web/AGENTS.md                                      |   20 +-
 web/fizzy-worker.js                                |   40 +-
 web/fizzy.js                                       | 1242 --------------
 web/index.html                                     | 1224 ++++++++++++-
 .../dvui/0001-web-highp-float-in-the-shaders.patch |  100 --
 ...use-events-carry-their-own-modifier-state.patch |  112 --
 ...l-is-the-mouse-and-a-cancelled-touch-ends.patch |  185 --
 ...web-send-only-the-GL-state-a-draw-changes.patch |  665 -------
 ...g-a-target-keeps-the-target-that-was-boun.patch |   45 -
 web/patches/dvui/0006-web-textureBlend.patch       |  217 ---
 .../dvui/0007-web-precise-render-targets.patch     |  339 ----
 ..._renderStream-a-flush-s-draws-in-one-call.patch |   98 --
 ...stom-fragment-programs-in-the-draw-stream.patch |  369 ----
 web/web.js                                         | 1813 ++++++++++++++++++++
 31 files changed, 3140 insertions(+), 3615 deletions(-)
Gates: 6 of 6 passed

scripts/check-fmt.sh (exit 0)

check-fmt: listing tracked files
check-fmt: checking 535 files

scripts/zb build --summary all (exit 0)

... (earlier output omitted)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- options (reused)
|     +- options (reused)
|     +- translate-c dvui-c cached
|     |  +- compile exe translate-c debug native (+21 more reused dependencies)
|     +- options cached
|     +- options cached
+- install text cached
|  +- compile lib text debug native cached 14ms MaxRSS:39M
|     +- WriteFile plugin_root.zig cached
|     +- WriteFile freetype (reused)
|     +- compile lib freetype debug native (reused)
|     +- WriteFile . (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- options (reused)
|     +- translate-c dvui-c (+1 more reused dependencies)
|     +- options (reused)
|     +- options (reused)
+- install markdown cached
|  +- compile lib markdown debug native cached 14ms MaxRSS:37M
|     +- WriteFile plugin_root.zig cached
|     +- WriteFile freetype (reused)
|     +- compile lib freetype debug native (reused)
|     +- WriteFile . (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- options (reused)
|     +- translate-c dvui-c (+1 more reused dependencies)
|     +- options (reused)
|     +- options (reused)
|     +- translate-c (reused)
+- install image cached
   +- compile lib image debug native cached 15ms MaxRSS:36M
      +- WriteFile plugin_root.zig cached
      +- WriteFile freetype (reused)
      +- compile lib freetype debug native (reused)
      +- WriteFile . (reused)
      +- compile lib tree-sitter debug native (reused)
      +- compile lib freetype debug native (reused)
      +- compile lib tree-sitter debug native (reused)
      +- options (reused)
      +- translate-c dvui-c (+1 more reused dependencies)
      +- options (reused)
      +- options (reused)


scripts/zb build test --summary all (exit 0)

... (earlier output omitted)
      +- WriteFile freetype cached
      +- compile lib freetype debug native cached 12ms MaxRSS:39M
      +- WriteFile . cached
      +- compile lib tree-sitter debug native cached 11ms MaxRSS:38M
      +- compile lib freetype debug native (reused)
      +- compile lib tree-sitter debug native (reused)
      +- translate-c dvui-c cached
      |  +- compile exe translate-c debug native cached 5ms MaxRSS:39M
      |     +- options cached
      |     +- options cached
      |     +- options cached
      |     +- run exe generate-def (aarch64.zig) cached
      |     |  +- compile exe generate-def debug native cached 4ms MaxRSS:39M
      |     +- run exe generate-def (amdgcn.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (arm.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (bpf.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (common.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (hexagon.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (loongarch.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (mips.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (neon.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (nvptx.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (powerpc.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (riscv.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (s390x.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (ve.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (wasm.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (x86_64.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (x86.zig) cached
      |     |  +- compile exe generate-def debug native (reused)
      |     +- run exe generate-def (xcore.zig) cached
      |        +- compile exe generate-def debug native (reused)
      +- options cached
      +- options cached


scripts/zb build test-integration --summary all (exit 0)

... (earlier output omitted)
|     +- options (reused)
|     +- options (reused)
+- run test fizzy-glass-tests cached
|  +- compile test fizzy-glass-tests debug native cached 14ms MaxRSS:37M
|     +- WriteFile freetype (reused)
|     +- compile lib freetype debug native (reused)
|     +- WriteFile . (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- translate-c dvui-c (+1 more reused dependencies)
|     +- options (reused)
|     +- options (reused)
+- run test fizzy-plugin-loader-tests cached
|  +- compile test fizzy-plugin-loader-tests debug native cached 13ms MaxRSS:39M
|     +- WriteFile freetype (reused)
|     +- compile lib freetype debug native (reused)
|     +- WriteFile . (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- translate-c dvui-c (+1 more reused dependencies)
|     +- options (reused)
|     +- options (reused)
+- run test fizzy-text-plugin-tests cached
|  +- compile test fizzy-text-plugin-tests debug native cached 15ms MaxRSS:39M
|     +- options (reused)
|     +- WriteFile freetype (reused)
|     +- compile lib freetype debug native (reused)
|     +- WriteFile . (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- compile lib freetype debug native (reused)
|     +- compile lib tree-sitter debug native (reused)
|     +- translate-c dvui-c (+1 more reused dependencies)
|     +- options (reused)
|     +- options (reused)
+- run test fizzy-workbench-plugin-tests cached
   +- compile test fizzy-workbench-plugin-tests debug native cached 15ms MaxRSS:34M
      +- options (reused)
      +- options (reused)
      +- WriteFile freetype (reused)
      +- compile lib freetype debug native (reused)
      +- WriteFile . (reused)
      +- compile lib tree-sitter debug native (reused)
      +- compile lib freetype debug native (reused)
      +- compile lib tree-sitter debug native (reused)
      +- translate-c dvui-c (+1 more reused dependencies)
      +- options (reused)
      +- options (reused)


scripts/zb build check-web --summary all (exit 0)

... (earlier output omitted)
|  |     +- run exe generate-def (amdgcn.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (arm.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (bpf.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (common.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (hexagon.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (loongarch.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (mips.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (neon.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (nvptx.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (powerpc.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (riscv.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (s390x.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (ve.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (wasm.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (x86_64.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (x86.zig) cached
|  |     |  +- compile exe generate-def debug native (reused)
|  |     +- run exe generate-def (xcore.zig) cached
|  |        +- compile exe generate-def debug native (reused)
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- options cached
|  +- translate-c cached 3ms MaxRSS:35M
+- compile obj rehome-fixture-web debug wasm32-freestanding cached 5ms MaxRSS:39M
   +- translate-c dvui-c (+1 more reused dependencies)
   +- options (reused)
   +- options (reused)


scripts/zb build test-sdk-version --summary all (exit 0)

... (earlier output omitted)
   +- WriteFile . cached
   +- compile lib tree-sitter debug native cached 9ms MaxRSS:33M
   +- compile lib freetype debug native (reused)
   +- compile lib tree-sitter debug native (reused)
   +- options cached
   +- options cached
   +- translate-c dvui-c cached
   |  +- compile exe translate-c debug native cached 6ms MaxRSS:39M
   |     +- options cached
   |     +- options cached
   |     +- options cached
   |     +- run exe generate-def (aarch64.zig) cached
   |     |  +- compile exe generate-def debug native cached 5ms MaxRSS:35M
   |     +- run exe generate-def (amdgcn.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (arm.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (bpf.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (common.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (hexagon.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (loongarch.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (mips.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (neon.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (nvptx.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (powerpc.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (riscv.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (s390x.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (ve.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (wasm.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (x86_64.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (x86.zig) cached
   |     |  +- compile exe generate-def debug native (reused)
   |     +- run exe generate-def (xcore.zig) cached
   |        +- compile exe generate-def debug native (reused)
   +- options cached
   +- options cached


pickUp flushed every closed document's pending track (pack, write, spin on the
checkpoint's writer) before reading a kept file. It now reads a waiting copy
from memory and leaves the write to the checkpoint's thread; only quitting
flushes.

Agent-Team: linux
Worker: claude
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fizzy-pm

fizzy-pm Bot commented Oct 26, 2026

Copy link
Copy Markdown

PM note: how this PR will be handled

What it is for: perf: pickup-no-flush
Issue #261: perf: picking a document back up never flushes pending checkpoint writes on the frame (follow-up of PR #804)
Done when (from the issue): draft PR under 200 lines; the test; frame time at pick-up with a pending write, before and after, in the body.

Rules that apply: none special.
Reviews needed: 1, from any other team or kind.
Needs the maintainer's explicit yes before merge: no

Things to watch (checked by rule):

  • the body names its work issue (Part of fizzyedit/work#N)
  • size within 800 lines outside tests and docs (36)
  • a gates section with what was run

What happens next:

  1. Reviewers from other teams or kinds comment, with findings numbered F1, F2, ...
  2. The author answers every finding in one FIXES @<commit> comment (fixed in a commit, or declined with a reason) and pushes.
  3. Reviewers re-review the new commit on their own.
  4. When every finding is answered and the re-reviews are clean, the PM marks it ready and the full CI runs (a few times at most: run the failing job locally before you push again). Only when CI passes does the PM look, and the PM gives the final okay.

A living status comment below is kept current. Nothing here is a merge decision.

@fizzy-pm

fizzy-pm Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Where this PR stands

Stage: Done: approved
Next: Waiting for the merge queue

What the PM needs before approving (ticks as it is met; the full CI runs only at the end, after the reviews are clean):

  • The body names its basis (Part of fizzyedit/work#N or a plan step)
  • Within the size limit: 63 of 800 lines outside tests and docs
  • The body shows which gates the author ran
  • No open findings at this commit
  • Every earlier finding was answered in a FIXES comment (1 answered)
  • Clean reviews at this commit from 1 kind: linux/codex, macos/agy (has 2)
  • Marked ready, which starts the full CI (the PM does this the moment the items above are met)
  • The full CI passes at this commit (CI is green)
  • The PM's final okay (pm-approval)

Reviews at the current commit (5dd049d):

Reviewer Verdict Findings
linux/codex clean none
macos/agy clean none

1 earlier review are for older commits and will be redone.

Latest fixes comment: https://github.com/fizzyedit/work/issues/372#issuecomment-6424652322 (1 finding answered)

Updated 2026-10-26 21:29 UTC by the PM. This comment is edited in place.

@fizzy-pm fizzy-pm Bot added the pm:fixes author fixes the must-fix items label Oct 26, 2026
@fizzy-linux fizzy-linux Bot added reviewing:linux-codex a linux/codex review is running reviewing:linux-agy a linux/agy review is running and removed reviewing:linux-agy a linux/agy review is running reviewing:linux-codex a linux/codex review is running labels Oct 26, 2026
@fizzy-pm fizzy-pm Bot added pm:fixes author fixes the must-fix items and removed pm:fixes author fixes the must-fix items labels Oct 26, 2026
A track the checkpoint's thread took (takeChanged) is no longer in pending
and not yet renamed into place, so a reopen read an absent or older file and
lost the restored history. pickUp now waits for writing to drain when its
file is not in pending: rare, so the common reopen stays off the writer.

Agent-Team: linux
Worker: claude

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fizzy-macos fizzy-macos Bot added reviewing:macos-agy a macos/agy review is running and removed reviewing:macos-agy a macos/agy review is running labels Oct 26, 2026
@fizzy-pm
fizzy-pm Bot marked this pull request as ready for review October 26, 2026 19:46
@fizzy-pm fizzy-pm Bot added pm:verify the same reviewer verifies the fixes reviewer:linux-codex the PM assigned linux/codex to review this PR and removed pm:fixes author fixes the must-fix items labels Oct 26, 2026
@fizzy-linux fizzy-linux Bot added reviewing:linux-codex a linux/codex review is running and removed reviewing:linux-codex a linux/codex review is running labels Oct 26, 2026
@fizzy-pm fizzy-pm Bot removed pm:verify the same reviewer verifies the fixes reviewer:linux-codex the PM assigned linux/codex to review this PR labels Oct 26, 2026
@fizzy-pm
fizzy-pm Bot added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 8b18948 Oct 26, 2026
22 checks passed
@fizzy-pm
fizzy-pm Bot deleted the perf/pickup-no-flush branch October 26, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants