Skip to content

Fix typing lag with high sample counts - #4132

Merged
michaelr524 merged 1 commit into
mainfrom
fix/typing-lag-autorun-off
Jul 5, 2026
Merged

michaelr524 merged 1 commit into
mainfrom
fix/typing-lag-autorun-off

Conversation

@michaelr524

Copy link
Copy Markdown
Collaborator

With auto-run off, typing was still laggy at high sample counts because the playground re-rendered the whole viewer tree on every keystroke: the simulation object was rebuilt each render, defeating memoization. This memoizes it, stabilizes the seed-randomize callback, and wraps the viewer in React.memo.

Measured with headless Chromium on a 15-distribution model, auto-run off: 21.6ms/keystroke at 100k samples before, 6.5ms after — same as the 1k-sample baseline. Verified auto-run mode still re-simulates and renders new variables.

Fixes #4057

🤖 Generated with Claude Code

The playground re-rendered the entire viewer tree on every keystroke:
the simulation object was rebuilt on each render, defeating memoization
downstream. Memoize it, stabilize the randomizeSeed callback, and wrap
ViewerWithMenuBar in React.memo.

Measured (headless chromium, 15-dist model, autorun off): 21.6ms/char
at 100k samples before, 6.5ms/char after (same as 1k baseline).

Fixes #4057

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michaelr524
michaelr524 requested review from OAGr and berekuk as code owners July 4, 2026 21:40
@github-project-automation github-project-automation Bot moved this to 🆕 To prioritize in Overview Jul 4, 2026
@vercel

vercel Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fermi-contest-2025-02 Ready Ready Preview Jul 4, 2026 9:44pm
metaforecast Ready Ready Preview Jul 4, 2026 9:44pm
quri-hub Ready Ready Preview Jul 4, 2026 9:44pm
quri-ui Ready Ready Preview Jul 4, 2026 9:44pm
squiggle-components Ready Ready Preview Jul 4, 2026 9:44pm
squiggle-website Ready Ready Preview Jul 4, 2026 9:44pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cdfe141

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@quri/squiggle-components Patch
vscode-squiggle Patch
@quri/versioned-squiggle-components Patch
@quri/squiggle-lang Patch
@quri/prettier-plugin-squiggle Patch
@quri/squiggle-textmate-grammar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch was successfully deployed

6 active deployments
Preview – quri-hub — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Preview – squiggle-website — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Preview – squiggle-components — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Preview – fermi-contest-2025-02 — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Preview – metaforecast — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Preview – quri-ui — cdfe1410 Deployed Jul 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

I set the number of samples to 100,000 and now typing is super laggy even though I turned off auto-run

1 participant