Skip to content

Commit

Permalink
compression/storage: Use preallocated lz4 blocks
Browse files Browse the repository at this point in the history
(cherry picked from commit 34860a9)
  • Loading branch information
abhijat committed Apr 12, 2024
1 parent 36382ea commit 6b282f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/v/compression/internal/lz4_frame_compressor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#include "compression/internal/lz4_frame_compressor.h"

#include "bytes/bytes.h"
#include "compression/lz4_decompression_buffers.h"
#include "static_deleter_fn.h"
#include "units.h"
#include "vassert.h"

#include <seastar/core/temporary_buffer.hh>

Expand Down Expand Up @@ -59,9 +58,12 @@ using lz4_decompression_ctx = std::unique_ptr<
&LZ4F_freeDecompressionContext>>;

static lz4_decompression_ctx make_decompression_context() {
LZ4F_dctx* c = nullptr;
LZ4F_errorCode_t code = LZ4F_createDecompressionContext(&c, LZ4F_VERSION);
check_lz4_error("LZ4F_createDecompressionContext error: {}", code);
LZ4F_dctx* c = LZ4F_createDecompressionContext_advanced(
lz4_decompression_buffers_instance().custom_mem_alloc(), LZ4F_VERSION);
if (c == nullptr) {
throw std::runtime_error("Failed to initialize decompression context");
}

return lz4_decompression_ctx(c);
}

Expand Down
1 change: 1 addition & 0 deletions src/v/compression/lz4_decompression_buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class lz4_decompression_buffers {
size_t deallocs{0};
size_t pass_through_allocs{0};
size_t pass_through_deallocs{0};
bool operator==(const stats&) const = default;
};

void allocated() { _allocation_stats.allocs += 1; }
Expand Down

0 comments on commit 6b282f6

Please sign in to comment.