mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
bz2: limit max concurrent CPU (#13458)
Ensure that bz2 decompression will never take more than 50% CPU.
This commit is contained in:
@@ -35,6 +35,9 @@ import (
|
||||
"github.com/pierrec/lz4"
|
||||
)
|
||||
|
||||
// Max bzip2 concurrency across calls. 50% of GOMAXPROCS.
|
||||
var bz2Limiter = pbzip2.CreateConcurrencyPool((runtime.GOMAXPROCS(0) + 1) / 2)
|
||||
|
||||
func detect(r *bufio.Reader) format {
|
||||
z, err := r.Peek(4)
|
||||
if err != nil {
|
||||
@@ -116,7 +119,9 @@ func untar(r io.Reader, putObject func(reader io.Reader, info os.FileInfo, name
|
||||
case formatBZ2:
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
r = pbzip2.NewReader(ctx, bf, pbzip2.DecompressionOptions(pbzip2.BZConcurrency((runtime.GOMAXPROCS(0)+1)/2)))
|
||||
r = pbzip2.NewReader(ctx, bf, pbzip2.DecompressionOptions(
|
||||
pbzip2.BZConcurrency((runtime.GOMAXPROCS(0)+1)/2),
|
||||
pbzip2.BZConcurrencyPool(bz2Limiter)))
|
||||
case formatLZ4:
|
||||
r = lz4.NewReader(bf)
|
||||
case formatUnknown:
|
||||
|
||||
Reference in New Issue
Block a user