Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor zstd decoder #498

Merged
merged 35 commits into from
Feb 24, 2022
Merged

Refactor zstd decoder #498

merged 35 commits into from
Feb 24, 2022

Conversation

klauspost
Copy link
Owner

@klauspost klauspost commented Feb 18, 2022

TLDR;

  • Streams can now be decoded without goroutines using WithDecoderConcurrency(1).

  • WithDecoderConcurrency(4) is now default. If you need more concurrent DecodeAll operations, use WithDecoderConcurrency(0).

Goroutines exit when streams have finished reading (either error or EOF).

Designed and tested to be compatible, but test before committing upgrade.

Changes

Goroutines will now only be created on demand, and WithDecoderConcurrency(1) is now strictly synchronized.

Decompression will typically be about 2x faster when using multiple goroutines, and will prepare input for the upstream reader async to reads. This can lead to ~3x faster input in total than using no goroutines.

New default is now WithDecoderConcurrency(4) (or less, if GOMAXPROCS is less). Beyond 4, there is little benefit for streaming decompression.

  • No goroutines created, unless streaming, and auto-closed at error/EOF.
  • Synchronous stream decoding with WithDecoderConcurrency(1).
  • Split sequence decoding/execution for streams up to 50% faster.
  • Simplified error flow.
  • Speedup on streams.
  • More consistent error reporting.
  • Improved error detection/compliance with reference decoder.
  • Improved test coverage.

Fixes #477

@klauspost klauspost marked this pull request as ready for review February 18, 2022 15:34
@klauspost klauspost merged commit 308a751 into master Feb 24, 2022
@klauspost klauspost deleted the refactor-zstd-decoder branch February 24, 2022 11:21
@klauspost klauspost mentioned this pull request Feb 28, 2022
1 task
dnwe pushed a commit to bgreenlee/sarama that referenced this pull request Dec 21, 2022
An upstream change in klauspost/compress#498 changed the default decoder
concurrency from GOMAXPROCS to a maximum of 4. Explicitly pass a value
of 0 via WithDecoderConcurrency so that GOMAXPROCS is used by default
again.
dnwe pushed a commit to IBM/sarama that referenced this pull request Dec 21, 2022
An upstream change in klauspost/compress#498 changed the default decoder
concurrency from GOMAXPROCS to a maximum of 4. Explicitly pass a value
of 0 via WithDecoderConcurrency so that GOMAXPROCS is used by default
again.
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.

Refactor zstd Decoder
1 participant