cli
cli copied to clipboard
Enhance docker system prune performance via concurrent pruning
Enhance docker system prune performance via concurrent pruning
Refactored the runPrune function to execute pruning operations concurrently:
- Added sync.WaitGroup to orchestrate goroutines
- Used sync/atomic for thread-safe space reclaimed counter
- Added mutex for safe slice operations (outputs and errors)
- Maintained the same CLI behavior with improved performance
- Order of outputs may differ from sequential execution
This change improves performance of the prune command, especially for systems with many Docker resources by executing independent pruning operations in parallel.
What I did
Modified the docker system prune command to execute all pruning operations (containers, networks, volumes, images, and build cache) concurrently instead of sequentially.
How I did it
- Introduced sync primitives (WaitGroup, Mutex, atomic) for safe concurrent execution
- Launched each pruning function in its own goroutine
- Safely aggregated results (space reclaimed, outputs, errors)
- Preserved the existing CLI behavior and output format
How to verify it
Run docker system prune on a system with many Docker resources and observe faster completion times compared to the previous sequential implementation.
Human readable description for the release notes
Improved performance of docker system prune by executing pruning operations concurrently
🐿️