Skip to content

perf(ui-egui): stop reading the disk on every frame - #386

Merged
DWAA1660 merged 7 commits into
AlienTechSoftware:mainfrom
leifrossau:perf/fewer-disk-reads-per-frame
Nov 18, 2026
Merged

DWAA1660 merged 7 commits into
AlienTechSoftware:mainfrom
leifrossau:perf/fewer-disk-reads-per-frame

Conversation

@leifrossau

Copy link
Copy Markdown
Collaborator

What and why

Drawing a page asked the disk about its files on every frame: two lookups per picture (image_bytes), the attachment and icon checks (first_missing_attachment_in_source), object_link per picture, a read of the selected page for the ribbon's shortcuts (hierarchy_keys), a read of every page in the section for Make Subpage (can_make_subpage), the page's ancestors for the New section button (new_section_parent), and up to three other-window change checks a frame. On a local disk that costs a few milliseconds. On a FUSE mount (OneDrive through onedriver) every open waits on the mount's process: on a page of 43 printouts frames took 40 to 170 ms and zoom and pan were choppy.

  • fscache.rs keeps file answers for two seconds and lets them go after any engine command, a page open or a finished printout.
  • The shortcuts read the disk only when a key goes down; New section uses the session's tree in memory.
  • The other-window check runs twice a second, and at once in any frame with a key, text, paste or click, so an edit is never made against a stale page.

Measured on the 43-printout page in a real window: 13,860 lookups and 1,140 opens a second down to about 110 and 60 (the last being settings.toml), none on the notebook; frames about 3 ms.

Quality level L3 (see SKILLS/nc-devx/SKILL.md)

  • cargo xtask pre-push passes on the current branch before pushing
  • The pre-push hook confirms the validation still matches origin/main
  • CI checks pass for this pull request
  • Coverage: the coverage job's warnings are read; cargo xtask coverage --update is in
    this pull request if coverage rose
  • Docs match the change: no command, control-protocol or gap changes
  • A new user action is a CommandSpec with a test (no new user action)
  • Page or demo changes: none
  • UI changes: no visual change
  • New files under assets/ or docs/images/ have a row in ATTRIBUTION.md (none added)

How it was checked

  • cargo xtask pre-push on this branch.
  • New test drawing_a_page_of_printouts_does_not_ask_the_disk_every_frame and fscache unit tests; a_changed_picture_is_read_again_under_a_new_name still passes (a command lets the cache go).
  • File calls counted with an LD_PRELOAD counter on a real window before and after; frame times from the same run. Not checked: Windows and macOS, where the cache only removes work.

🤖 Generated with Claude Code

leifrossau and others added 3 commits November 18, 2026 20:02
Drawing a page asked about its files every frame: two lookups per
picture, attachment and icon checks, a read of the page for the ribbon's
shortcuts, a read of every page in the section for Make Subpage, the
page's ancestors for the New section button, and three checks a frame
for another window's writes. On a local disk that is a few milliseconds;
on a FUSE mount such as OneDrive through onedriver every open waits on
the mount, and a page of printouts drew a few frames a second.

File answers are now kept for two seconds (fscache) and let go after any
command or page open; the shortcuts read the disk only when a key goes
down; New section uses the tree in memory; the other-window check runs
twice a second and before any key, text or click. Measured on a page of
43 printouts: 13,860 lookups and 1,140 opens a second down to about 110
and 60, none of them on the notebook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mameen
mameen requested a balanced review from Copilot November 18, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

leifrossau and others added 4 commits November 18, 2026 22:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The web build (Build website WASM) failed: preview.rs takes `std` from the web shim, so its SystemTime is web-time's, while fscache.rs used the real one, and asked the real disk, which the browser has none of. fscache.rs now gets the same one-line rule as preview.rs in patches.yaml, and its modification time comes from a function that is None on wasm (the shim's Metadata has none).
fscache.rs asks std::fs::metadata for the pictures preview.rs draws. In the browser it now asks the in-memory notebook and uses the same web-time SystemTime as preview.rs, which fixes the Build website WASM type errors.
@DWAA1660
DWAA1660 enabled auto-merge November 18, 2026 22:10
@DWAA1660
DWAA1660 merged commit 470ae21 into AlienTechSoftware:main Nov 18, 2026
14 checks passed
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.

3 participants