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

What's the recommended way of reusing one context for buffers of different size? #140

Open
v-chernyshev opened this issue Jul 16, 2020 · 0 comments

Comments

@v-chernyshev
Copy link

Good afternoon, I did a quick test of blosc V2 and saw that its compression ratio was much worse than what I used to get with V1. I've traced it to the btune_next_blocksize function:

c-blosc2/blosc/btune.c

Lines 53 to 56 in 50a7357

if (user_blocksize) {
blocksize = user_blocksize;
goto last;
}

Essentially what happens is that when context->blocksize is set to zero it is eventually initialised based on the very first buffer that is passed into blosc2_compress_ctx, in my case it was a very small array that caused the calculated blocksize to be set to 96. Subsequent calls to btune_next_blocksize then treat this 96 as a user-supplied block size, which leads to almost no compression of bigger buffers.

The only way I see to "fix" it while, at the same time, keeping automatic block size deduction, is to include context.h and reset blocksize to zero before calling blosc2_compress_ctx, but there is a comment in the header that says that the context is an opaque type. Is there a better way to do it? Thanks!

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

No branches or pull requests

1 participant