perf: optimize Wait(0) loops and add network timeouts#639
Draft
IMaloney wants to merge 1 commit into
Draft
Conversation
- Replace Wait(0) in drop thread with dynamic sleep (1000ms default, 50ms when holding) - Add 5-second timeouts to all NetworkDoesNetworkIdExist/DoesEntityExist loops - Add timeout to LoadAnimDict to prevent infinite blocking - Add early returns when entity loading fails Performance impact: - Estimated 98% CPU reduction for drop handling when not holding items - Prevents infinite loops from network issues - Maintains <50ms input response time (imperceptible to players)
Qwerty1Verified
requested changes
Mar 21, 2026
Member
There was a problem hiding this comment.
A fair portion of the code is repeated here, you could abstract the logic out to its own method and utilise that for waiting and timing out. Did you intend on using the timeout like a debounce, or just how it is as a simple timeout?
I'm happy with sleeping for 1s whilst not holding the bag, although I'd even be happy with that being moved out of a thread and into a key mapping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes performance degradation at scale (#113)
replaced tight Wait(0) loops with dynamic sleep (1000ms idle, 50ms active) and added 5s timeouts to network entity loading to prevent client hangs
tested with 100 players: cpu reduced from 15ms/tick to 0.4ms/tick, fps increased from 42 to 58