mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 15:35:55 +03:00
[PR #916] [CLOSED] perf: Reuse rand for shuffling queues #2933
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#2933
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hibiken/asynq/pull/916
Author: @l0nax
Created: 9/12/2024
Status: ❌ Closed
Base:
master← Head:perf-reuse-rand📝 Commits (1)
f4d037fperf: Reuse rand for shuffling queues📊 Changes
1 file changed (+6 additions, -2 deletions)
View changed files
📝
processor.go(+6 -2)📄 Description
Instead of creating a new
rand.Randevery time we need the next queues, we create it once and reuse it.The reason for this change comes from monitoring our application: After a few minutes, the
github.com/hibiken/asynq.(*processor).queuesmethod will consume a tremendous amount of CPU time and create a lot of garbage.Since the
queuemethod is called in its own goroutine, there is no need to add any synchronization primitives.Here is the profiling flame graph of our application in a time window of 5 minutes:

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.