Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Cyan4973
Copy link
Member

@Cyan4973 Cyan4973 commented Sep 8, 2022

as noted by @yixiutt in #1157, the temporary buffer managed by lz4frame compression context is being invalidated at end of compression, forcing it to be re-allocated at next compression job.

This shouldn't be necessary.
This behavior was introduced in #236, as a way to fix #232, but neither the issue is explained, nor why the patch fixes it.

This patch reverts to previous behavior,
where temporary buffer is reused between compression calls.
This results in a net reduction of allocation workload.

Additionally, the temporary buffer should only need malloc(), not calloc(), thus saving some potential 0-initialization cost.

This diff implements both changes. It's expected to improve compression speed when repetitively compressing small data.

Performance impact on M1 laptop :

filename size cSpeed before cSpeed after delta
enwik7 1000000 485 MB/s 485 MB/s +0%
enwik6 100000 505 MB/s 508 MB/s +1%
enwik5 10000 862 MB/s 1037 MB/s +20%
enwik4 1000 359 MB/s 940 MB/s +160%

As expected, performance difference is only perceptible for small data, but it can matter a lot in this case.

Once this diff is merged, long fuzzer tests will be run to ensure that no sanitizer warning gets triggered.

Additionally :

  • fixed a minor ubsan warning in LZ4F_decompress()
  • added an LZ4F_compressUpdate() test to fullbench

as noted by @yixiutt, the temporary buffer inside lz4frame compression
is being invalidated at end of compression,
forcing it to be re-allocated at next compression job.

This shouldn't be necessary.
This change was introduced in #236, as a way to fix #232,
but neither the issue is explained, nor why the patch fixes it.

This patch revert to previous behavior,
where temporary buffer is kept between compression calls.
This results in a net reduction of allocation workload.

Additionally, the temporary buffer should only need malloc(),
not calloc(), thus saving initialization.

This diff implements both changes.
Long fuzzer tests will be run to ensure that no sanitizer warning get triggered.

Additionally :
fixed a minor ubsan warning in LZ4F_decompress().
@yixiutt
Copy link

yixiutt commented Sep 8, 2022

LGTM

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.

A bug in frametest

3 participants