perf(grammar): check only the paragraphs that changed #829
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
project-halkyon/halkyon-learn!829
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/829/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A check walked the whole document and posted every segment, one
awaitafter another, on every pause in typing. A ten-paragraph note therefore
cost ten sequential round trips through the Edge Function to LanguageTool
for a single edited character — nine of them re-asking about text nobody
had touched. The wait scaled with the size of the note rather than the
size of the edit, which is the wrong axis: the longer a note grows, the
more it stalls on each pause.
Matches are now cached per exact segment text. LanguageTool is a pure
function of (text, language) and the language is fixed for a controller's
lifetime, so an untouched paragraph produces a byte-identical key and its
previous verdict stands. Typing costs one request. Two identical
paragraphs in one document cost one between them. The cache is rebuilt
from the segments each completed run actually saw, so it can't grow across
a long editing session, and a failed segment is deliberately never
recorded — it has to retry.
Offsets survive the reuse because the key IS the text the offsets index;
a cached match maps onto whatever path that paragraph sits at now, even if
it moved.
Runs no longer overlap. The idle timer, the blur flush and the
attach-time
checkNowcould each start a full pass over the samedocument, and a blur landing just after the timer fired doubled the
traffic outright. A pass now runs alone, with at most one rerun coalesced
behind it.
The overlay stops rebuilding for nothing.
_recomputeransetStateunconditionally — on every controller notification and once per frame
while the editor scrolls — rebuilding one
GestureDetectorper squiggleeven when the geometry was identical. It now compares first. The
comparison includes the controller status, not just the rects: the build
reads
statusfor the "checked, no issues" checkmark, and only arecompute can rebuild this widget, so a status change with unchanged
geometry still has to get through.
Three spans are traced (
grammar.segment,grammar.request,grammar.overlay.recompute) behind the existingHALKYON_PERF_TRACEdefine, so what remains of a stall can be attributed rather than guessed
at.
Signed-off-by: Tizian 「ティツィアーン」 raisondetredev@pm.me