Skip to content

perf: use FpsScheduler for solo network mode efficiency#7657

Merged
mimecuvalo merged 9 commits intomainfrom
mime/120fps-x2-sync
Jan 21, 2026
Merged

perf: use FpsScheduler for solo network mode efficiency#7657
mimecuvalo merged 9 commits intomainfrom
mime/120fps-x2-sync

Conversation

@mimecuvalo
Copy link
Copy Markdown
Member

@mimecuvalo mimecuvalo commented Jan 8, 2026

parent PR: #7418
this makes just the solo mode change for better network usage.

pr-7657-walkthrough.mp4

Change type

  • bugfix
  • improvement
  • feature
  • api
  • other

Note

Optimizes network scheduling and reduces solo-mode traffic by using a dedicated FPS-based scheduler.

  • Introduces FpsScheduler instance in TLSyncClient to throttle network operations independently of UI
  • Adds dynamic sync rates: SOLO_MODE_FPS = 1, COLLABORATIVE_MODE_FPS = 30; updates target FPS based on presenceMode
  • Replaces fpsThrottle with fpsScheduler.fpsThrottle for flushPendingPushRequests and scheduleRebase
  • Adds getSyncFps() and calls updateTargetFps during presence reactions; minor debug log on push send
  • Removes old fpsThrottle-based implementations

Written by Cursor Bugbot for commit 2f029e7. This will update automatically on new commits. Configure here.

@mimecuvalo mimecuvalo requested a review from steveruizok January 8, 2026 17:12
@huppy-bot huppy-bot bot added the improvement Product improvement label Jan 8, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 8, 2026

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

Project Deployment Review Updated (UTC)
analytics Ready Ready Preview Jan 21, 2026 9:21am
examples Ready Ready Preview Jan 21, 2026 9:21am
tldraw-docs Ready Ready Preview Jan 21, 2026 9:21am
3 Skipped Deployments
Project Deployment Review Updated (UTC)
chat-template Ignored Ignored Jan 21, 2026 9:21am
tldraw-shader Ignored Ignored Jan 21, 2026 9:21am
workflow-template Ignored Ignored Jan 21, 2026 9:21am

Request Review

@huppy-bot
Copy link
Copy Markdown
Contributor

huppy-bot bot commented Jan 8, 2026

Hey! 👋

This PR contains changes to api-report.api.md, which means you've made some API changes. To help reviewers and SDK users understand the impact, please add a "### API changes" section to your PR description.

Here's an example:

### API changes
- Describe what API changes were made
- List any breaking changes
- Note any new or removed parameters

Once you add this section, the check will pass automatically!

@mimecuvalo mimecuvalo changed the base branch from main to mime/120fps-x2 January 12, 2026 10:38
@mimecuvalo
Copy link
Copy Markdown
Member Author

(forgot to change base branch, that was done just now @MitjaBezensek )

@vercel vercel bot temporarily deployed to Preview – workflow-template January 12, 2026 15:51 Inactive
@vercel vercel bot temporarily deployed to Preview – tldraw-shader January 12, 2026 15:51 Inactive
@vercel vercel bot temporarily deployed to Preview – chat-template January 12, 2026 15:51 Inactive
@MitjaBezensek
Copy link
Copy Markdown
Contributor

(forgot to change base branch, that was done just now @MitjaBezensek )

No worries. I reviewed the parent pr, will take a look at this first thing tomorrow.

Copy link
Copy Markdown
Contributor

@MitjaBezensek MitjaBezensek left a comment

Choose a reason for hiding this comment

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

👏

@mimecuvalo
Copy link
Copy Markdown
Member Author

going to wait land this until a week after the parent PR is in prod

github-merge-queue bot pushed a commit that referenced this pull request Jan 14, 2026
…7418)

once more with feeling. the previous attempts were trying to put
schedule UI and network events on the same queue, which ... I don't know
what we were thinking :P
Anyway, this creates a proper FpsScheduler class that can take different
target rates which solves the issues we were seeing. But also, it solves
the fact that even without the 120fps change, we shouldn't be combining
these queues.

I recommend reviewing this PR with "hide whitespace" on. you'll note
that it had less changes than you would expect. it's really more about
just creating a JS class to encapsulate the throttle queue.

this lays the groundwork for the child PR here that does the network bit
of this: #7657

previous PRs: #6868 to
#6470

### Change type

- [ ] `bugfix`
- [x] `improvement`
- [ ] `feature`
- [ ] `api`
- [ ] `other`

### Test plan

- [x] Unit tests (if present)
- [ ] End to end tests (if present)

### Release notes

- Improved performance by separating UI and network scheduling queues.

### API changes

- adds `FpsScheduler` to be able to create a FPS-throttled queue of
functions to execute



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Introduce per-instance FPS scheduling**
> 
> - Add `FpsScheduler` class in `lib/throttle` with its own queue/state
and configurable target FPS; create a default 120fps instance and have
`fpsThrottle`/`throttleToNextFrame` delegate to it
> - Export `FpsScheduler` from `utils` (`src/index.ts`); update API
report accordingly
> - Add comprehensive unit tests (`lib/throttle.test.ts`) covering
throttling, next-frame batching, cancelation, and real-world scenarios
> - UI tweak: `DefaultDebugPanel` FPS readout now includes `maxKnownFps`
(`FPS ${fps} (max: ${maxKnownFps})`)
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
871ad95. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Base automatically changed from mime/120fps-x2 to main January 14, 2026 11:40
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
agent-template 2f029e7 Jan 21 2026, 09:13 AM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Jan 21, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
multiplayer-template 2f029e7 Jan 21 2026, 09:17 AM

@mimecuvalo mimecuvalo added the dotcom-preview-please ⚙️ Deploys a preview of tldraw.com for this PR label Jan 21, 2026
@mimecuvalo mimecuvalo added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit c080470 Jan 21, 2026
20 of 23 checks passed
@mimecuvalo mimecuvalo deleted the mime/120fps-x2-sync branch January 21, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotcom-preview-please ⚙️ Deploys a preview of tldraw.com for this PR improvement Product improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants