refactor: rework the worker manager for performance#110
Merged
1Lucas1apk merged 1 commit intoPerformanC:v3from Nov 1, 2025
Merged
refactor: rework the worker manager for performance#1101Lucas1apk merged 1 commit intoPerformanC:v3from
1Lucas1apk merged 1 commit intoPerformanC:v3from
Conversation
Signed-off-by: toddynnn <86982643+ToddyTheNoobDud@users.noreply.github.com>
1Lucas1apk
approved these changes
Nov 1, 2025
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.
Changes
Added this.workerToGuilds = new Map() on constructor, this goes from an O(n) to a O(1), providing better speed
Added this.workersById = new Map(), this also enables O(1) lookups for more speed
Reworked scaleWorkers(), this removes the excessive interactions of filtering and array creations, converted to a for const with a single pass interaction
Added caching on scalingConfig to avoid repeating objects acess
Added batching to stats updates (every 100ms) to reduce overhead
getBestWorker has been rewrited to use the least-loaded worker instead of using round-robin for selecting workers.
Improved the failure history to use a slice(-5) instead of shift(), slice uses O(k), beign slighly more performant than shift()
Why
This should reduce the garbage collection overload/pressure, also should improve the workers distribution for loading and reduce the overhead while maintaining more speed
Checkmarks
Additional information
i request for an actual testing on this before "merging" if this happens, i want to check if this actually helps reducing the cpu and memory load, any feedback will be good