-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[zstd] pass level param through to compress/zstd encoder #2045
Conversation
closing/reopening to possibly get CLA status to refresh? there we go. |
1680e0a
to
c9e4131
Compare
@lizthegrey thanks for these changes, I'm happy to approve as I think we should be exposing the level FWIW we previously had a PR from someone (#1869) suggesting that Aside, whilst it doesn't strictly need it at the moment (because we're not exposing any options), could you mirror the use of a sync.Map in the decode case too so that the decoder is only initialised on-demand in a similar way? I know people have been interesting in customising the encoder and decoder so I think this would be a good step toward exposing more options going forward. |
Do you prefer use of a Pool or of a single returned |
Or we could create a |
@lizthegrey historically this was due to the use of the klaus/compress library for zstd which differs from compress/gzip and /pierrec/lz4, because it manages its own sync.Pool of encoders/decoders and spawns goroutines when you invoke it (see compress#264 for some of the old context) |
Done, there's now both ZstdDecoderParams and ZstdEncoderParams and lazy-creation when a decoder or encoder is requested with a new set of parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
I'm also open to explicitly enumerating the encoder categories as was done with gzip, but decided to do the sync.Map approach instead for simplicity in case the number range changes meaning down the road and we need more or fewer numbers, etc.
https://pkg.go.dev/sync#Map says it's okay to use it as it fits
(1) the entry for a given key is only ever written once but read many times, as in caches that only grow