Skip to content

Reduce goroutine count for processing expiration func#177

Merged
kpango merged 1 commit into
mainfrom
refactor/reduce-goroutine-count-for-expiration-channel
Mar 23, 2026
Merged

Reduce goroutine count for processing expiration func#177
kpango merged 1 commit into
mainfrom
refactor/reduce-goroutine-count-for-expiration-channel

Conversation

@kpango
Copy link
Copy Markdown
Owner

@kpango kpango commented Mar 10, 2026

This pull request introduces improvements to the concurrency handling for expired item processing in the gache cache implementation. The main changes are the adoption of the errgroup package for managing goroutines, which allows for better control and error handling, and the addition of the new dependency in go.mod.

Concurrency improvements:

  • Replaced manual goroutine spawning in StartExpired with errgroup, enabling structured concurrency and limiting the number of concurrent goroutines to twice the number of CPU cores. This ensures more robust error handling and resource management.
  • Changed context handling in StartExpired to use the errgroup context, improving cancellation and synchronization of goroutines.

Dependency updates:

  • Added golang.org/x/sync (which provides errgroup) to go.mod to support the new concurrency model.
  • Imported golang.org/x/sync/errgroup in gache.go to enable usage of the errgroup package.

Signed-off-by: kpango <kpango@vdaas.org>
@kpango kpango merged commit 91652ee into main Mar 23, 2026
5 checks passed
@kpango kpango deleted the refactor/reduce-goroutine-count-for-expiration-channel branch March 23, 2026 03:20
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.

1 participant