Repository navigation
enhance(editor): keep per-keystroke bookkeeping out of the app state store - #13210
yuxi-liu-wired wants to merge 2 commits into
Conversation
d18fdc7 to
abe8fda
Compare
|
Rebased onto current master, still one commit. The lint pass that followed #13211 removed |
1240192 to
abe8fda
Compare
|
Rebased the branch onto current Review result: the mechanism checks out — no store subscriber or imperative One simplification committed on top ( Validation: |
UI verification — editor bookkeeping moved to plain atomsBuilt the web app with Verified:
Not covered: the narrow |
…store Every keystroke wrote four values through state/set-state!: the block text, the last input time, the last key code, and the saved cursor position. Each write makes the state store re-evaluate every mounted subscription, so on a page with many blocks a keystroke ran that sweep four times. The last input time, the last key code, the saved cursor, and the UI's last key code are read imperatively by the editor handlers through their getters; no component subscribes to them. Keep them in plain atoms, remove their keys from the store's initial state and from the places that reset them, and drop the store save/restore of the saved cursor from state_test. A keystroke now writes the store once, for the text. Measured on a 2,000-page graph, typing into a block on a 204 KB page (key press to next frame, p50 / p90 / max, 83 keys): before 44.7 / 50.7 / 66.3 ms, after this change 34.9 / 49.5 / 88.3 ms.
:editor/last-key-code was only ever written, never read (the store key had no getter; the keyup handler stored a map that nothing consumed). Keeping it as a private atom preserves dead bookkeeping, so remove the atom, the setter, and its call sites entirely.
abe8fda to
ba8bf40
Compare
|
Rebased onto current master and took the follow-up commit from The failed "Test editor" run on the previous head stopped at the job's 8-minute limit, which #13426 has since raised to 12. |
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
What changes
A keystroke in the editor writes the app state store once (the block text) instead of 5 times.
Mechanism
Every keystroke wrote
:editor/content,:editor/last-input-time,:editor/last-key-code,:editor/last-saved-cursorand:ui/global-last-key-codethroughstate/set-state!. Each write makes the rfx store re-evaluate every mounted subscription, so on a page with many blocks a keystroke paid that sweep 5 times. Nothing subscribes to the 4 bookkeeping values; they are read imperatively (state/input-idle?,state/get-editor-last-pos,state/get-ui-last-key-code). They now live in plain atoms infrontend.state, reset whereclear-edit!andset-editing!reset them, with the same getters and setters.Numbers
Typing into a block on a 204 KB page of a 2,000 page graph, key press to next frame, p50 / p90 / max over 83 keys at a 60 ms cadence, Chromium 148 renderer driven over the DevTools protocol: before 44.7 / 50.7 / 66.3 ms, after 34.9 / 49.5 / 88.3 ms. Keyup handling per key dropped from 32 ms (Event Timing
keyupduration p50) to under 16 ms.Tests
The existing unit suite, compiled with
pnpm cljs:testand run with the grouping ofbb dev:run-test-namespaces(213 namespaces, 2106 tests, 8650 assertions): every test passes exceptfrontend.handler.db-based.import-test/import-from-sqlite-db-persists-import-marker-through-worker-test, whose 5 assertions fail identically on unpatched master (be800f1) whenever that namespace shares a node process with the 6 namespaces the runner groups it with, and pass when the namespace runs alone. With one node process per namespace the suite is fully green on this change. No new test: the change moves values between storage mechanisms with identical getters.Link to Devin session: https://app.devin.ai/sessions/a0806935382643ff89101cd35b49ffdb
Open in Devin Desktop: https://app.devin.ai/desktop/session/a0806935382643ff89101cd35b49ffdb?variant=devin
Requested by: @tiensonqin