Skip to content

Conversation

@aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Dec 12, 2025

Description

Under high concurrency, multiple calls to JobsMap.get() could each spawn a gc() goroutine if lastGC was stale, causing unnecessary goroutine accumulation while they wait for the lock.

Add an atomic gcRunning flag with compare-and-swap to ensure only one gc goroutine runs at a time. The flag is reset after gc() completes.

Link to tracking issue

Fixes

Testing

Documentation

Under high concurrency, multiple calls to JobsMap.get() could each spawn
a gc() goroutine if lastGC was stale, causing unnecessary goroutine
accumulation while they wait for the lock.

Add an atomic gcRunning flag with compare-and-swap to ensure only one
gc goroutine runs at a time. The flag is reset after gc() completes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 force-pushed the fix/gc-goroutine-accumulation branch from 907db0f to 885d1fe Compare December 12, 2025 15:59
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