Skip to content

Improve SocketIO Performance#269

Merged
1cedsoda merged 16 commits intomasterfrom
improve-socket-perf
Jun 16, 2025
Merged

Improve SocketIO Performance#269
1cedsoda merged 16 commits intomasterfrom
improve-socket-perf

Conversation

@1cedsoda
Copy link
Copy Markdown
Contributor

@1cedsoda 1cedsoda commented Jun 2, 2025

fix #357

  • Using global event queue to send out events
  • Events are sent from separate socket-queue and not blocking the LoopThread
  • Use MessagePack encoding
  • Throttle setState triggered by events to 60fps
  • Don't use Zod's parse function
  • Don't use produce for state updates triggered by events

@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch 9 times, most recently from 6292862 to 533d6fd Compare June 2, 2025 15:12
@1cedsoda 1cedsoda marked this pull request as ready for review June 2, 2025 15:13
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch from 533d6fd to be41a42 Compare June 5, 2025 17:19
@1cedsoda 1cedsoda requested a review from Copilot June 5, 2025 17:20

This comment was marked as outdated.

@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch 2 times, most recently from ce29f7e to 9179d09 Compare June 6, 2025 10:50
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch from 9179d09 to ff30a0b Compare June 6, 2025 11:55
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch from ff30a0b to d136032 Compare June 6, 2025 15:04
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch 3 times, most recently from 0bb9d81 to 0df95dd Compare June 16, 2025 14:14
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch from 71dfbfb to 2459d82 Compare June 16, 2025 15:59
@1cedsoda 1cedsoda force-pushed the improve-socket-perf branch from fbc4a73 to 727a87e Compare June 16, 2025 16:18
@1cedsoda 1cedsoda requested a review from Copilot June 16, 2025 16:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves SocketIO performance by implementing a global event queue, removing blocking operations, and introducing MessagePack encoding while also optimizing state updates to 60 FPS via a throttled updater. Key changes include replacing immer’s produce with a custom ThrottledStoreUpdater, removing the useThrottle hook from several modules, and updating the namespace disconnection timeout.

Reviewed Changes

Copilot reviewed 49 out of 50 changed files in this pull request and generated no comments.

Show a summary per file
File Description
electron/src/machines/winder/winder2/winder2Namespace.ts Replaces immer produce with a throttled updater for state changes
electron/src/machines/mock/mock1/* Removes useThrottle logic and updates event handling to use throttled updater
electron/src/machines/laser/laser1/* Applies similar state update changes and removes unneeded throttling
electron/src/machines/extruder/extruder2/* Adopts the throttled updater for state changes, eliminating delayed throttling calls
electron/src/lib/useThrottle.ts Entire file removed as throttling is now handled via ThrottledStoreUpdater
electron/src/client/socketioStore.ts Introduces ThrottledStoreUpdater and MessagePack parser; updates namespace disconnect timeout
control-core/* Removes per-socket queues in favor of a global event queue and converts event data to a boxed erased serializer
Files not reviewed (1)
  • electron/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

electron/src/client/socketioStore.ts:409

  • The disconnect timeout log message was updated from 10s to 1h. Please update any accompanying documentation or inline comments to clearly explain this change so that future maintainers understand the rationale behind the increased inactivity timeout.
console.log(`Namespace ${namespace_path} disconnected after 1h of inactivity`);

@1cedsoda 1cedsoda merged commit ebbd4a5 into master Jun 16, 2025
4 checks passed
@1cedsoda 1cedsoda deleted the improve-socket-perf branch June 16, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use MessagePack for SocketIO Communication

2 participants