Do not spam events when the Engine gives a lot of updates#532
Do not spam events when the Engine gives a lot of updates#532TurtleOrangina wants to merge 2 commits intofranciscoBSalgueiro:masterfrom
Conversation
9628708 to
b7ce153
Compare
521b046 to
7e6722d
Compare
|
great pull request.. plss add this |
Adapted from TurtleOrangina's PR #532 on upstream en-croissant. Adds time-based buffering to engine analysis events so the UI isn't drinking from a firehose: - Wait 200ms before first update (let engine reach meaningful depth) - Hold subsequent updates for 500ms minimum between emissions - Flush buffered payload after 1000ms max so UI doesn't feel frozen - BestMove always emits immediately (engine finished) This complements the React-side fix (PR #725) which reduced the cost per event. This fix reduces the frequency of events. Belt and suspenders. Credit: TurtleOrangina (upstream PR franciscoBSalgueiro/en-croissant#532) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Worth noting: this PR and PR##725 are solving different sides of the same problem. Think of it like drinking from a firehose. This PR #532 (@TurtleOrangina's fix) turns down the water pressure — it reduces the frequency of events by buffering on the Rust side. Instead of blasting the UI with every depth update (especially the garbage depths 1–5 in the first 200ms), it holds back and only sends updates the human can actually read. PR#725 (#725) swallows faster — it reduces the cost of each engine event hitting the UI. Before, every event triggered O(N) selector evaluations across all notation cells. Now the parent subscribes once and passes cheap props down. Each gulp is cheap instead of choking. Either fix alone helps significantly. Together they're belt-and-suspenders — the UI receives fewer events AND each event costs less to process. The two PRs touch completely different files (Rust backend vs React frontend) so they merge cleanly with no conflicts. I've implemented both in my fork and the result is noticeably smoother than either fix alone. |
Fixes #530
Directly in the rust code that parses the Engine suggestions:
Example (engine pondering for some position):