@ -228,15 +228,21 @@ public:
|
|||||||
void purge_extra_cached_block(int keep) {
|
void purge_extra_cached_block(int keep) {
|
||||||
for(int i = MAX_ARENA_NUM - 1; i >= keep; i--) {
|
for(int i = MAX_ARENA_NUM - 1; i >= keep; i--) {
|
||||||
Arena& arena = arena_[i];
|
Arena& arena = arena_[i];
|
||||||
|
arena.ref(1);
|
||||||
Block* old_blk = arena.clear();
|
Block* old_blk = arena.clear();
|
||||||
if (NULL != old_blk) {
|
if (NULL != old_blk) {
|
||||||
int64_t old_pos = INT64_MAX;
|
int64_t old_pos = INT64_MAX;
|
||||||
if (old_blk->freeze(old_pos)) {
|
if (old_blk->freeze(old_pos)) {
|
||||||
|
arena.ref(-1);
|
||||||
arena.sync();
|
arena.sync();
|
||||||
if (old_blk->retire(old_pos)) {
|
if (old_blk->retire(old_pos)) {
|
||||||
destroy_block(old_blk);
|
destroy_block(old_blk);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
arena.ref(-1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
arena.ref(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
deps/oblib/src/lib/compress/ob_compress_util.h
vendored
20
deps/oblib/src/lib/compress/ob_compress_util.h
vendored
@ -14,6 +14,7 @@
|
|||||||
#define OB_COMPRESSOR_UTIL_H_
|
#define OB_COMPRESSOR_UTIL_H_
|
||||||
#include "lib/ob_define.h"
|
#include "lib/ob_define.h"
|
||||||
#include "lib/utility/ob_template_utils.h"
|
#include "lib/utility/ob_template_utils.h"
|
||||||
|
#include "lib/allocator/ob_allocator.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
@ -72,4 +73,23 @@ const char *const compress_funcs[] =
|
|||||||
} /* namespace common */
|
} /* namespace common */
|
||||||
} /* namespace oceanbase */
|
} /* namespace oceanbase */
|
||||||
|
|
||||||
|
using oceanbase::common::ObIAllocator;
|
||||||
|
static void *ob_zstd_malloc(void *opaque, size_t size)
|
||||||
|
{
|
||||||
|
void *buf = NULL;
|
||||||
|
if (NULL != opaque) {
|
||||||
|
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
||||||
|
buf = allocator->alloc(size);
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ob_zstd_free(void *opaque, void *address)
|
||||||
|
{
|
||||||
|
if (NULL != opaque) {
|
||||||
|
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
||||||
|
allocator->free(address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OB_COMPRESSOR_UTIL_H_ */
|
#endif /* OB_COMPRESSOR_UTIL_H_ */
|
||||||
|
|||||||
24
deps/oblib/src/lib/compress/ob_compressor.h
vendored
24
deps/oblib/src/lib/compress/ob_compressor.h
vendored
@ -29,28 +29,6 @@ public:
|
|||||||
ObCompressor() {}
|
ObCompressor() {}
|
||||||
virtual ~ObCompressor() {}
|
virtual ~ObCompressor() {}
|
||||||
|
|
||||||
virtual int compress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size,
|
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
|
||||||
UNUSED(allocator);
|
|
||||||
return compress(src_buffer, src_data_size, dst_buffer, dst_buffer_size,
|
|
||||||
dst_data_size);
|
|
||||||
}
|
|
||||||
virtual int decompress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size,
|
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
|
||||||
UNUSED(allocator);
|
|
||||||
return decompress(src_buffer, src_data_size, dst_buffer, dst_buffer_size,
|
|
||||||
dst_data_size);
|
|
||||||
}
|
|
||||||
virtual int compress(const char *src_buffer,
|
virtual int compress(const char *src_buffer,
|
||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
@ -63,8 +41,6 @@ public:
|
|||||||
int64_t &dst_data_size) = 0;
|
int64_t &dst_data_size) = 0;
|
||||||
virtual int get_max_overflow_size(const int64_t src_data_size,
|
virtual int get_max_overflow_size(const int64_t src_data_size,
|
||||||
int64_t &max_overflow_size) const = 0;
|
int64_t &max_overflow_size) const = 0;
|
||||||
virtual void reset_mem() {}
|
|
||||||
|
|
||||||
virtual const char *get_compressor_name() const = 0;
|
virtual const char *get_compressor_name() const = 0;
|
||||||
virtual ObCompressorType get_compressor_type() const = 0;
|
virtual ObCompressorType get_compressor_type() const = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,17 +17,20 @@ namespace oceanbase
|
|||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
ObCompressorPool::ObCompressorPool()
|
ObCompressorPool::ObCompressorPool()
|
||||||
:none_compressor(),
|
:allocator_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, "Compressor")), OB_MALLOC_BIG_BLOCK_SIZE),
|
||||||
|
none_compressor(),
|
||||||
lz4_compressor(),
|
lz4_compressor(),
|
||||||
lz4_compressor_1_9_1(),
|
lz4_compressor_1_9_1(),
|
||||||
snappy_compressor(),
|
snappy_compressor(),
|
||||||
zlib_compressor(),
|
zlib_compressor(),
|
||||||
zstd_compressor_1_3_8(),
|
zstd_compressor(allocator_),
|
||||||
|
zstd_compressor_1_3_8(allocator_),
|
||||||
zlib_lite_compressor(),
|
zlib_lite_compressor(),
|
||||||
lz4_stream_compressor(),
|
lz4_stream_compressor(),
|
||||||
zstd_stream_compressor(),
|
zstd_stream_compressor(allocator_),
|
||||||
zstd_stream_compressor_1_3_8()
|
zstd_stream_compressor_1_3_8(allocator_)
|
||||||
{
|
{
|
||||||
|
allocator_.set_nway(32);
|
||||||
}
|
}
|
||||||
ObCompressorPool &ObCompressorPool::get_instance()
|
ObCompressorPool &ObCompressorPool::get_instance()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "lib/compress/ob_compressor.h"
|
#include "lib/compress/ob_compressor.h"
|
||||||
#include "lib/compress/ob_stream_compressor.h"
|
#include "lib/compress/ob_stream_compressor.h"
|
||||||
|
#include "lib/allocator/ob_vslice_alloc.h"
|
||||||
#include "none/ob_none_compressor.h"
|
#include "none/ob_none_compressor.h"
|
||||||
#include "lz4/ob_lz4_compressor.h"
|
#include "lz4/ob_lz4_compressor.h"
|
||||||
#include "snappy/ob_snappy_compressor.h"
|
#include "snappy/ob_snappy_compressor.h"
|
||||||
@ -62,6 +63,7 @@ private:
|
|||||||
ObCompressorPool();
|
ObCompressorPool();
|
||||||
virtual ~ObCompressorPool() {}
|
virtual ~ObCompressorPool() {}
|
||||||
|
|
||||||
|
ObVSliceAlloc allocator_;
|
||||||
ObNoneCompressor none_compressor;
|
ObNoneCompressor none_compressor;
|
||||||
ObLZ4Compressor lz4_compressor;
|
ObLZ4Compressor lz4_compressor;
|
||||||
ObLZ4Compressor191 lz4_compressor_1_9_1;
|
ObLZ4Compressor191 lz4_compressor_1_9_1;
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "ob_zstd_compressor.h"
|
#include "ob_zstd_compressor.h"
|
||||||
#include "lib/ob_errno.h"
|
#include "lib/ob_errno.h"
|
||||||
|
#include "lib/rc/context.h"
|
||||||
#include "lib/thread_local/ob_tsi_factory.h"
|
#include "lib/thread_local/ob_tsi_factory.h"
|
||||||
#include "ob_zstd_wrapper.h"
|
#include "ob_zstd_wrapper.h"
|
||||||
|
|
||||||
@ -20,57 +21,6 @@ using namespace common;
|
|||||||
using namespace zstd;
|
using namespace zstd;
|
||||||
|
|
||||||
|
|
||||||
static void *ob_zstd_malloc(void *opaque, size_t size)
|
|
||||||
{
|
|
||||||
void *buf = NULL;
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
|
||||||
buf = allocator->alloc(size);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ob_zstd_free(void *opaque, void *address)
|
|
||||||
{
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
|
||||||
allocator->free(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ------------------------------ObZstdCtxAllocator---------------------
|
|
||||||
*/
|
|
||||||
ObZstdCtxAllocator::ObZstdCtxAllocator(int64_t tenant_id)
|
|
||||||
: allocator_(ObModIds::OB_COMPRESSOR, ZSTD_ALLOCATOR_BLOCK_SIZE,
|
|
||||||
tenant_id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ObZstdCtxAllocator::~ObZstdCtxAllocator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ObZstdCtxAllocator::alloc(const int64_t size)
|
|
||||||
{
|
|
||||||
return allocator_.alloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::free(void *ptr)
|
|
||||||
{
|
|
||||||
allocator_.free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::reuse()
|
|
||||||
{
|
|
||||||
allocator_.reuse();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::reset()
|
|
||||||
{
|
|
||||||
allocator_.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ----------------------------ObZstdCompressor---------------------------
|
* ----------------------------ObZstdCompressor---------------------------
|
||||||
*/
|
*/
|
||||||
@ -78,14 +28,12 @@ int ObZstdCompressor::compress(const char *src_buffer,
|
|||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size)
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
int64_t max_overflow_size = 0;
|
int64_t max_overflow_size = 0;
|
||||||
size_t compress_ret_size = 0;
|
size_t compress_ret_size = 0;
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, allocator ?: &zstd_allocator};
|
|
||||||
dst_data_size = 0;
|
dst_data_size = 0;
|
||||||
|
|
||||||
if (NULL == src_buffer
|
if (NULL == src_buffer
|
||||||
@ -113,7 +61,6 @@ int ObZstdCompressor::compress(const char *src_buffer,
|
|||||||
dst_data_size = compress_ret_size;
|
dst_data_size = compress_ret_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
zstd_allocator.reuse();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,13 +68,11 @@ int ObZstdCompressor::decompress(const char *src_buffer,
|
|||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size)
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
size_t decompress_ret_size = 0;
|
size_t decompress_ret_size = 0;
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, allocator ?: &zstd_allocator};
|
|
||||||
dst_data_size = 0;
|
dst_data_size = 0;
|
||||||
|
|
||||||
if (NULL == src_buffer
|
if (NULL == src_buffer
|
||||||
@ -148,16 +93,9 @@ int ObZstdCompressor::decompress(const char *src_buffer,
|
|||||||
} else {
|
} else {
|
||||||
dst_data_size = decompress_ret_size;
|
dst_data_size = decompress_ret_size;
|
||||||
}
|
}
|
||||||
zstd_allocator.reuse();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObZstdCompressor::reset_mem()
|
|
||||||
{
|
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
|
||||||
zstd_allocator.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ObZstdCompressor::get_compressor_name() const
|
const char *ObZstdCompressor::get_compressor_name() const
|
||||||
{
|
{
|
||||||
return all_compressor_name[ObCompressorType::ZSTD_COMPRESSOR];
|
return all_compressor_name[ObCompressorType::ZSTD_COMPRESSOR];
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
#ifndef OCEANBASE_COMMON_COMPRESS_ZSTD_COMPRESSOR_
|
#ifndef OCEANBASE_COMMON_COMPRESS_ZSTD_COMPRESSOR_
|
||||||
#define OCEANBASE_COMMON_COMPRESS_ZSTD_COMPRESSOR_
|
#define OCEANBASE_COMMON_COMPRESS_ZSTD_COMPRESSOR_
|
||||||
#include "lib/compress/ob_compressor.h"
|
#include "lib/compress/ob_compressor.h"
|
||||||
#include "lib/allocator/page_arena.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
@ -23,66 +22,28 @@ namespace common
|
|||||||
namespace zstd
|
namespace zstd
|
||||||
{
|
{
|
||||||
|
|
||||||
class ObZstdCtxAllocator : public ObIAllocator
|
|
||||||
{
|
|
||||||
static constexpr int64_t ZSTD_ALLOCATOR_BLOCK_SIZE = (1LL << 20) - (17LL << 10);
|
|
||||||
public:
|
|
||||||
ObZstdCtxAllocator(int64_t tenant_id);
|
|
||||||
virtual ~ObZstdCtxAllocator();
|
|
||||||
static ObZstdCtxAllocator &get_thread_local_instance()
|
|
||||||
{
|
|
||||||
thread_local ObZstdCtxAllocator allocator(ob_thread_tenant_id());
|
|
||||||
return allocator;
|
|
||||||
}
|
|
||||||
void *alloc(const int64_t size) override;
|
|
||||||
void *alloc(const int64_t size, const ObMemAttr &attr) override { return NULL; }
|
|
||||||
void free(void *ptr) override;
|
|
||||||
void reuse() override;
|
|
||||||
void reset() override;
|
|
||||||
private:
|
|
||||||
ObArenaAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObZstdCompressor : public ObCompressor
|
class ObZstdCompressor : public ObCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ObZstdCompressor() {}
|
explicit ObZstdCompressor(ObIAllocator &allocator)
|
||||||
|
: allocator_(allocator) {}
|
||||||
virtual ~ObZstdCompressor() {}
|
virtual ~ObZstdCompressor() {}
|
||||||
int compress(const char *src_buffer,
|
int compress(const char *src_buffer,
|
||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size) override;
|
||||||
ObIAllocator *allocator) override;
|
|
||||||
int decompress(const char *src_buffer,
|
int decompress(const char *src_buffer,
|
||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size) override;
|
||||||
ObIAllocator *allocator) override;
|
|
||||||
int compress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size) override
|
|
||||||
{
|
|
||||||
return compress(src_buffer, src_data_size, dst_buffer,
|
|
||||||
dst_buffer_size, dst_data_size, NULL);
|
|
||||||
}
|
|
||||||
int decompress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size) override
|
|
||||||
{
|
|
||||||
return decompress(src_buffer, src_data_size, dst_buffer,
|
|
||||||
dst_buffer_size, dst_data_size, NULL);
|
|
||||||
}
|
|
||||||
const char *get_compressor_name() const;
|
const char *get_compressor_name() const;
|
||||||
ObCompressorType get_compressor_type() const;
|
ObCompressorType get_compressor_type() const;
|
||||||
int get_max_overflow_size(const int64_t src_data_size,
|
int get_max_overflow_size(const int64_t src_data_size,
|
||||||
int64_t &max_overflow_size) const;
|
int64_t &max_overflow_size) const;
|
||||||
void reset_mem();
|
private:
|
||||||
|
ObIAllocator &allocator_;
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace zstd
|
} // namespace zstd
|
||||||
|
|||||||
@ -20,47 +20,6 @@ using namespace oceanbase;
|
|||||||
using namespace common;
|
using namespace common;
|
||||||
using namespace zstd;
|
using namespace zstd;
|
||||||
|
|
||||||
static void *ob_zstd_stream_malloc(void *opaque, size_t size)
|
|
||||||
{
|
|
||||||
void *buf = NULL;
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObZstdStreamCtxAllocator *allocator = reinterpret_cast<ObZstdStreamCtxAllocator*> (opaque);
|
|
||||||
buf = allocator->alloc(size);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ob_zstd_stream_free(void *opaque, void *address)
|
|
||||||
{
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObZstdStreamCtxAllocator *allocator = reinterpret_cast<ObZstdStreamCtxAllocator*> (opaque);
|
|
||||||
allocator->free(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ------------------------------ObZstdStreamCtxAllocator---------------------
|
|
||||||
*/
|
|
||||||
ObZstdStreamCtxAllocator::ObZstdStreamCtxAllocator()
|
|
||||||
: allocator_(ObModIds::OB_STREAM_COMPRESSOR, OB_SERVER_TENANT_ID)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ObZstdStreamCtxAllocator::~ObZstdStreamCtxAllocator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ObZstdStreamCtxAllocator::alloc(size_t size)
|
|
||||||
{
|
|
||||||
return allocator_.alloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdStreamCtxAllocator::free(void *addr)
|
|
||||||
{
|
|
||||||
allocator_.free(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------ObZstdStreamCompressor---------------------
|
* ------------------------------ObZstdStreamCompressor---------------------
|
||||||
*/
|
*/
|
||||||
@ -79,8 +38,7 @@ int ObZstdStreamCompressor::create_compress_ctx(void *&ctx)
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
ObZstdStreamCtxAllocator &zstd_allocator = ObZstdStreamCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_stream_malloc, ob_zstd_stream_free, &zstd_allocator};
|
|
||||||
if (OB_FAIL(ObZstdWrapper::create_cctx(zstd_mem, ctx))) {
|
if (OB_FAIL(ObZstdWrapper::create_cctx(zstd_mem, ctx))) {
|
||||||
LIB_LOG(WARN, "failed to create cctx", K(ret));
|
LIB_LOG(WARN, "failed to create cctx", K(ret));
|
||||||
}
|
}
|
||||||
@ -146,8 +104,7 @@ int ObZstdStreamCompressor::stream_compress(void *ctx, const char *src, const in
|
|||||||
int ObZstdStreamCompressor::create_decompress_ctx(void *&ctx)
|
int ObZstdStreamCompressor::create_decompress_ctx(void *&ctx)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObZstdStreamCtxAllocator &zstd_allocator = ObZstdStreamCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_stream_malloc, ob_zstd_stream_free, &zstd_allocator};
|
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
if (OB_FAIL(ObZstdWrapper::create_dctx(zstd_mem, ctx))) {
|
if (OB_FAIL(ObZstdWrapper::create_dctx(zstd_mem, ctx))) {
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
#define OCEANBASE_COMMON_STREAM_COMPRESS_ZSTD_COMPRESSOR_
|
#define OCEANBASE_COMMON_STREAM_COMPRESS_ZSTD_COMPRESSOR_
|
||||||
|
|
||||||
#include "lib/compress/ob_stream_compressor.h"
|
#include "lib/compress/ob_stream_compressor.h"
|
||||||
#include "lib/allocator/page_arena.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
@ -23,26 +22,11 @@ namespace common
|
|||||||
namespace zstd
|
namespace zstd
|
||||||
{
|
{
|
||||||
|
|
||||||
class ObZstdStreamCtxAllocator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ObZstdStreamCtxAllocator();
|
|
||||||
virtual ~ObZstdStreamCtxAllocator();
|
|
||||||
static ObZstdStreamCtxAllocator &get_thread_local_instance()
|
|
||||||
{
|
|
||||||
thread_local ObZstdStreamCtxAllocator allocator;
|
|
||||||
return allocator;
|
|
||||||
}
|
|
||||||
void *alloc(size_t size);
|
|
||||||
void free(void *addr);
|
|
||||||
private:
|
|
||||||
ModulePageAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObZstdStreamCompressor : public ObStreamCompressor
|
class ObZstdStreamCompressor : public ObStreamCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ObZstdStreamCompressor() {}
|
explicit ObZstdStreamCompressor(ObIAllocator &allocator)
|
||||||
|
: allocator_(allocator) {}
|
||||||
virtual ~ObZstdStreamCompressor() {}
|
virtual ~ObZstdStreamCompressor() {}
|
||||||
|
|
||||||
const char *get_compressor_name() const;
|
const char *get_compressor_name() const;
|
||||||
@ -63,7 +47,8 @@ public:
|
|||||||
|
|
||||||
int get_compress_bound_size(const int64_t src_size, int64_t &bound_size) const;
|
int get_compress_bound_size(const int64_t src_size, int64_t &bound_size) const;
|
||||||
int insert_uncompressed_block(void *dctx, const void *block, const int64_t block_size);
|
int insert_uncompressed_block(void *dctx, const void *block, const int64_t block_size);
|
||||||
|
private:
|
||||||
|
ObIAllocator &allocator_;
|
||||||
};
|
};
|
||||||
} // namespace zstd
|
} // namespace zstd
|
||||||
} //namespace common
|
} //namespace common
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include "ob_zstd_compressor_1_3_8.h"
|
#include "ob_zstd_compressor_1_3_8.h"
|
||||||
|
|
||||||
#include "lib/ob_errno.h"
|
#include "lib/ob_errno.h"
|
||||||
|
#include "lib/rc/context.h"
|
||||||
#include "lib/thread_local/ob_tsi_factory.h"
|
#include "lib/thread_local/ob_tsi_factory.h"
|
||||||
#include "ob_zstd_wrapper.h"
|
#include "ob_zstd_wrapper.h"
|
||||||
|
|
||||||
@ -21,57 +22,6 @@ using namespace common;
|
|||||||
using namespace zstd_1_3_8;
|
using namespace zstd_1_3_8;
|
||||||
|
|
||||||
|
|
||||||
static void *ob_zstd_malloc(void *opaque, size_t size)
|
|
||||||
{
|
|
||||||
void *buf = NULL;
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
|
||||||
buf = allocator->alloc(size);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ob_zstd_free(void *opaque, void *address)
|
|
||||||
{
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObIAllocator *allocator = reinterpret_cast<ObIAllocator*> (opaque);
|
|
||||||
allocator->free(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ------------------------------ObZstdCtxAllocator---------------------
|
|
||||||
*/
|
|
||||||
ObZstdCtxAllocator::ObZstdCtxAllocator(int64_t tenant_id)
|
|
||||||
: allocator_(ObModIds::OB_COMPRESSOR, ZSTD_ALLOCATOR_BLOCK_SIZE,
|
|
||||||
tenant_id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ObZstdCtxAllocator::~ObZstdCtxAllocator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ObZstdCtxAllocator::alloc(const int64_t size)
|
|
||||||
{
|
|
||||||
return allocator_.alloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::free(void *ptr)
|
|
||||||
{
|
|
||||||
allocator_.free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::reuse()
|
|
||||||
{
|
|
||||||
allocator_.reuse();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdCtxAllocator::reset()
|
|
||||||
{
|
|
||||||
allocator_.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ----------------------------ObZstdCompressor---------------------------
|
* ----------------------------ObZstdCompressor---------------------------
|
||||||
*/
|
*/
|
||||||
@ -79,14 +29,12 @@ int ObZstdCompressor_1_3_8::compress(const char *src_buffer,
|
|||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size)
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
int64_t max_overflow_size = 0;
|
int64_t max_overflow_size = 0;
|
||||||
size_t compress_ret_size = 0;
|
size_t compress_ret_size = 0;
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, allocator ?: &zstd_allocator};
|
|
||||||
dst_data_size = 0;
|
dst_data_size = 0;
|
||||||
|
|
||||||
if (NULL == src_buffer
|
if (NULL == src_buffer
|
||||||
@ -114,7 +62,6 @@ int ObZstdCompressor_1_3_8::compress(const char *src_buffer,
|
|||||||
dst_data_size = compress_ret_size;
|
dst_data_size = compress_ret_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
zstd_allocator.reuse();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,13 +69,11 @@ int ObZstdCompressor_1_3_8::decompress(const char *src_buffer,
|
|||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size)
|
||||||
ObIAllocator *allocator)
|
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
size_t decompress_ret_size = 0;
|
size_t decompress_ret_size = 0;
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, allocator ?: &zstd_allocator};
|
|
||||||
dst_data_size = 0;
|
dst_data_size = 0;
|
||||||
|
|
||||||
if (NULL == src_buffer
|
if (NULL == src_buffer
|
||||||
@ -150,16 +95,9 @@ int ObZstdCompressor_1_3_8::decompress(const char *src_buffer,
|
|||||||
dst_data_size = decompress_ret_size;
|
dst_data_size = decompress_ret_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
zstd_allocator.reuse();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObZstdCompressor_1_3_8::reset_mem()
|
|
||||||
{
|
|
||||||
ObZstdCtxAllocator &zstd_allocator = ObZstdCtxAllocator::get_thread_local_instance();
|
|
||||||
zstd_allocator.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *ObZstdCompressor_1_3_8::get_compressor_name() const
|
const char *ObZstdCompressor_1_3_8::get_compressor_name() const
|
||||||
{
|
{
|
||||||
return all_compressor_name[ObCompressorType::ZSTD_1_3_8_COMPRESSOR];
|
return all_compressor_name[ObCompressorType::ZSTD_1_3_8_COMPRESSOR];
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
#ifndef OCEANBASE_COMMON_COMPRESS_ZSTD_1_3_8_COMPRESSOR_
|
#ifndef OCEANBASE_COMMON_COMPRESS_ZSTD_1_3_8_COMPRESSOR_
|
||||||
#define OCEANBASE_COMMON_COMPRESS_ZSTD_1_3_8_COMPRESSOR_
|
#define OCEANBASE_COMMON_COMPRESS_ZSTD_1_3_8_COMPRESSOR_
|
||||||
#include "lib/compress/ob_compressor.h"
|
#include "lib/compress/ob_compressor.h"
|
||||||
#include "lib/allocator/page_arena.h"
|
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
@ -23,66 +22,28 @@ namespace common
|
|||||||
namespace zstd_1_3_8
|
namespace zstd_1_3_8
|
||||||
{
|
{
|
||||||
|
|
||||||
class ObZstdCtxAllocator : public ObIAllocator
|
|
||||||
{
|
|
||||||
static constexpr int64_t ZSTD_ALLOCATOR_BLOCK_SIZE = (1LL << 20) - (17LL << 10);
|
|
||||||
public:
|
|
||||||
ObZstdCtxAllocator(int64_t tenant_id);
|
|
||||||
virtual ~ObZstdCtxAllocator();
|
|
||||||
static ObZstdCtxAllocator &get_thread_local_instance()
|
|
||||||
{
|
|
||||||
thread_local ObZstdCtxAllocator allocator(ob_thread_tenant_id());
|
|
||||||
return allocator;
|
|
||||||
}
|
|
||||||
void *alloc(const int64_t size) override;
|
|
||||||
void *alloc(const int64_t size, const ObMemAttr &attr) override { return NULL; }
|
|
||||||
void free(void *ptr) override;
|
|
||||||
void reuse() override;
|
|
||||||
void reset() override;
|
|
||||||
private:
|
|
||||||
ObArenaAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class __attribute__((visibility ("default"))) ObZstdCompressor_1_3_8 : public ObCompressor
|
class __attribute__((visibility ("default"))) ObZstdCompressor_1_3_8 : public ObCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ObZstdCompressor_1_3_8() {}
|
explicit ObZstdCompressor_1_3_8(ObIAllocator &allocator)
|
||||||
|
: allocator_(allocator) {}
|
||||||
virtual ~ObZstdCompressor_1_3_8() {}
|
virtual ~ObZstdCompressor_1_3_8() {}
|
||||||
int compress(const char *src_buffer,
|
int compress(const char *src_buffer,
|
||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size) override;
|
||||||
ObIAllocator *allocator) override;
|
|
||||||
int decompress(const char *src_buffer,
|
int decompress(const char *src_buffer,
|
||||||
const int64_t src_data_size,
|
const int64_t src_data_size,
|
||||||
char *dst_buffer,
|
char *dst_buffer,
|
||||||
const int64_t dst_buffer_size,
|
const int64_t dst_buffer_size,
|
||||||
int64_t &dst_data_size,
|
int64_t &dst_data_size) override;
|
||||||
ObIAllocator *allocator) override;
|
|
||||||
int compress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size) override
|
|
||||||
{
|
|
||||||
return compress(src_buffer, src_data_size, dst_buffer,
|
|
||||||
dst_buffer_size, dst_data_size, NULL);
|
|
||||||
}
|
|
||||||
int decompress(const char *src_buffer,
|
|
||||||
const int64_t src_data_size,
|
|
||||||
char *dst_buffer,
|
|
||||||
const int64_t dst_buffer_size,
|
|
||||||
int64_t &dst_data_size) override
|
|
||||||
{
|
|
||||||
return decompress(src_buffer, src_data_size, dst_buffer,
|
|
||||||
dst_buffer_size, dst_data_size, NULL);
|
|
||||||
}
|
|
||||||
const char *get_compressor_name() const;
|
const char *get_compressor_name() const;
|
||||||
ObCompressorType get_compressor_type() const;
|
ObCompressorType get_compressor_type() const;
|
||||||
int get_max_overflow_size(const int64_t src_data_size,
|
int get_max_overflow_size(const int64_t src_data_size,
|
||||||
int64_t &max_overflow_size) const;
|
int64_t &max_overflow_size) const;
|
||||||
void reset_mem();
|
private:
|
||||||
|
ObIAllocator &allocator_;
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace zstd_1_3_8
|
} // namespace zstd_1_3_8
|
||||||
|
|||||||
@ -21,47 +21,6 @@ using namespace oceanbase;
|
|||||||
using namespace common;
|
using namespace common;
|
||||||
using namespace zstd_1_3_8;
|
using namespace zstd_1_3_8;
|
||||||
|
|
||||||
static void *ob_zstd_stream_malloc(void *opaque, size_t size)
|
|
||||||
{
|
|
||||||
void *buf = NULL;
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObZstdStreamCtxAllocator *allocator = reinterpret_cast<ObZstdStreamCtxAllocator*> (opaque);
|
|
||||||
buf = allocator->alloc(size);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ob_zstd_stream_free(void *opaque, void *address)
|
|
||||||
{
|
|
||||||
if (NULL != opaque) {
|
|
||||||
ObZstdStreamCtxAllocator *allocator = reinterpret_cast<ObZstdStreamCtxAllocator*> (opaque);
|
|
||||||
allocator->free(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ------------------------------ObZstdStreamCtxAllocator---------------------
|
|
||||||
*/
|
|
||||||
ObZstdStreamCtxAllocator::ObZstdStreamCtxAllocator()
|
|
||||||
: allocator_(ObModIds::OB_STREAM_COMPRESSOR, OB_SERVER_TENANT_ID)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ObZstdStreamCtxAllocator::~ObZstdStreamCtxAllocator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ObZstdStreamCtxAllocator::alloc(size_t size)
|
|
||||||
{
|
|
||||||
return allocator_.alloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObZstdStreamCtxAllocator::free(void *addr)
|
|
||||||
{
|
|
||||||
allocator_.free(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------ObZstdStreamCompressor---------------------
|
* ------------------------------ObZstdStreamCompressor---------------------
|
||||||
*/
|
*/
|
||||||
@ -81,8 +40,7 @@ int ObZstdStreamCompressor_1_3_8::create_compress_ctx(void *&ctx)
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
ObZstdStreamCtxAllocator &zstd_allocator = ObZstdStreamCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_stream_malloc, ob_zstd_stream_free, &zstd_allocator};
|
|
||||||
if (OB_FAIL(ObZstdWrapper::create_cctx(zstd_mem, ctx))) {
|
if (OB_FAIL(ObZstdWrapper::create_cctx(zstd_mem, ctx))) {
|
||||||
LIB_LOG(WARN, "failed to create cctx", K(ret));
|
LIB_LOG(WARN, "failed to create cctx", K(ret));
|
||||||
}
|
}
|
||||||
@ -148,8 +106,7 @@ int ObZstdStreamCompressor_1_3_8::stream_compress(void *ctx, const char *src, co
|
|||||||
int ObZstdStreamCompressor_1_3_8::create_decompress_ctx(void *&ctx)
|
int ObZstdStreamCompressor_1_3_8::create_decompress_ctx(void *&ctx)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObZstdStreamCtxAllocator &zstd_allocator = ObZstdStreamCtxAllocator::get_thread_local_instance();
|
OB_ZSTD_customMem zstd_mem = {ob_zstd_malloc, ob_zstd_free, &allocator_};
|
||||||
OB_ZSTD_customMem zstd_mem = {ob_zstd_stream_malloc, ob_zstd_stream_free, &zstd_allocator};
|
|
||||||
ctx = NULL;
|
ctx = NULL;
|
||||||
|
|
||||||
if (OB_FAIL(ObZstdWrapper::create_dctx(zstd_mem, ctx))) {
|
if (OB_FAIL(ObZstdWrapper::create_dctx(zstd_mem, ctx))) {
|
||||||
|
|||||||
@ -23,26 +23,11 @@ namespace common
|
|||||||
namespace zstd_1_3_8
|
namespace zstd_1_3_8
|
||||||
{
|
{
|
||||||
|
|
||||||
class ObZstdStreamCtxAllocator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ObZstdStreamCtxAllocator();
|
|
||||||
virtual ~ObZstdStreamCtxAllocator();
|
|
||||||
static ObZstdStreamCtxAllocator &get_thread_local_instance()
|
|
||||||
{
|
|
||||||
thread_local ObZstdStreamCtxAllocator allocator;
|
|
||||||
return allocator;
|
|
||||||
}
|
|
||||||
void *alloc(size_t size);
|
|
||||||
void free(void *addr);
|
|
||||||
private:
|
|
||||||
ModulePageAllocator allocator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ObZstdStreamCompressor_1_3_8 : public ObStreamCompressor
|
class ObZstdStreamCompressor_1_3_8 : public ObStreamCompressor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ObZstdStreamCompressor_1_3_8() {}
|
explicit ObZstdStreamCompressor_1_3_8(ObIAllocator &allocator)
|
||||||
|
: allocator_(allocator) {}
|
||||||
virtual ~ObZstdStreamCompressor_1_3_8() {}
|
virtual ~ObZstdStreamCompressor_1_3_8() {}
|
||||||
|
|
||||||
inline const char *get_compressor_name() const;
|
inline const char *get_compressor_name() const;
|
||||||
@ -63,7 +48,8 @@ public:
|
|||||||
|
|
||||||
int get_compress_bound_size(const int64_t src_size, int64_t &bound_size) const;
|
int get_compress_bound_size(const int64_t src_size, int64_t &bound_size) const;
|
||||||
int insert_uncompressed_block(void *dctx, const void *block, const int64_t block_size);
|
int insert_uncompressed_block(void *dctx, const void *block, const int64_t block_size);
|
||||||
|
private:
|
||||||
|
ObIAllocator &allocator_;
|
||||||
};
|
};
|
||||||
} // namespace zstd_1_3_8
|
} // namespace zstd_1_3_8
|
||||||
} //namespace common
|
} //namespace common
|
||||||
|
|||||||
2
deps/oblib/src/rpc/obrpc/ob_rpc_packet.h
vendored
2
deps/oblib/src/rpc/obrpc/ob_rpc_packet.h
vendored
@ -17,7 +17,7 @@
|
|||||||
#include "lib/profile/ob_trace_id.h"
|
#include "lib/profile/ob_trace_id.h"
|
||||||
#include "lib/utility/ob_print_utils.h"
|
#include "lib/utility/ob_print_utils.h"
|
||||||
#include "lib/checksum/ob_crc64.h"
|
#include "lib/checksum/ob_crc64.h"
|
||||||
#include "lib/compress/ob_compressor_pool.h"
|
#include "lib/compress/ob_compressor.h"
|
||||||
#include "rpc/obrpc/ob_rpc_time.h"
|
#include "rpc/obrpc/ob_rpc_time.h"
|
||||||
#include "rpc/ob_packet.h"
|
#include "rpc/ob_packet.h"
|
||||||
#include "common/errsim_module/ob_errsim_module_type.h"
|
#include "common/errsim_module/ob_errsim_module_type.h"
|
||||||
|
|||||||
1
deps/oblib/unittest/lib/CMakeLists.txt
vendored
1
deps/oblib/unittest/lib/CMakeLists.txt
vendored
@ -132,3 +132,4 @@ oblib_addtest(codec/test_fast_delta.cpp)
|
|||||||
oblib_addtest(codec/test_bitpacking.cpp)
|
oblib_addtest(codec/test_bitpacking.cpp)
|
||||||
oblib_addtest(codec/test_codec_performance.cpp)
|
oblib_addtest(codec/test_codec_performance.cpp)
|
||||||
oblib_addtest(codec/test_bitpacking_performance.cpp)
|
oblib_addtest(codec/test_bitpacking_performance.cpp)
|
||||||
|
oblib_addtest(compress/test_compressor_pool.cpp)
|
||||||
|
|||||||
@ -199,6 +199,7 @@ void TestCompressorStress::run1()
|
|||||||
class ObCompressorTest : public testing::Test
|
class ObCompressorTest : public testing::Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ObCompressorTest() : zstd_compressor(alloc) {}
|
||||||
static void SetUpTestCase()
|
static void SetUpTestCase()
|
||||||
{
|
{
|
||||||
memset(const_cast<char *>(compress_buffer), '\0', 100);
|
memset(const_cast<char *>(compress_buffer), '\0', 100);
|
||||||
@ -215,6 +216,7 @@ public:
|
|||||||
static char decompress_buffer[1000];
|
static char decompress_buffer[1000];
|
||||||
static int64_t buffer_size;
|
static int64_t buffer_size;
|
||||||
static int64_t dst_data_size;
|
static int64_t dst_data_size;
|
||||||
|
ObMalloc alloc;
|
||||||
ObNoneCompressor none_compressor;
|
ObNoneCompressor none_compressor;
|
||||||
ObLZ4Compressor lz4_compressor;
|
ObLZ4Compressor lz4_compressor;
|
||||||
ObSnappyCompressor snappy_compressor;
|
ObSnappyCompressor snappy_compressor;
|
||||||
@ -383,7 +385,8 @@ TEST(ObCompressorStress, compress_stable)
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
const int64_t sleep_sec = 1;
|
const int64_t sleep_sec = 1;
|
||||||
TestCompressorStress cmp_stress;
|
TestCompressorStress cmp_stress;
|
||||||
ObZstdCompressor zstd_compressor;
|
ObMalloc alloc;
|
||||||
|
ObZstdCompressor zstd_compressor(alloc);
|
||||||
|
|
||||||
ret = cmp_stress.init(30000, 100000, &zstd_compressor);
|
ret = cmp_stress.init(30000, 100000, &zstd_compressor);
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
ASSERT_EQ(OB_SUCCESS, ret);
|
||||||
@ -556,85 +559,6 @@ public:
|
|||||||
int64_t free_count_;
|
int64_t free_count_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void test_zstd_family(ObCompressor &compressor)
|
|
||||||
{
|
|
||||||
MyAlloc alloc;
|
|
||||||
ASSERT_EQ(alloc.alloc_count_, 0);
|
|
||||||
ASSERT_EQ(alloc.free_count_, alloc.alloc_count_);
|
|
||||||
int64_t src_len = 2L<<20;
|
|
||||||
char *src_buf = (char*)ob_malloc(src_len, "test");
|
|
||||||
for (int i = 0; i < src_len; i++) {
|
|
||||||
src_buf[i] = static_cast<char> ('a' + ObRandom::rand(0, 25));;
|
|
||||||
}
|
|
||||||
char *cmp_buf = (char*)ob_malloc(src_len, "test");
|
|
||||||
memcpy(cmp_buf, src_buf, src_len);
|
|
||||||
int64_t max_overflow_size = 0;
|
|
||||||
int ret = compressor.get_max_overflow_size(src_len, max_overflow_size);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
int64_t dst_buf_len = src_len + max_overflow_size;
|
|
||||||
char *dst_buf = (char*)ob_malloc(dst_buf_len, "test");
|
|
||||||
int64_t dst_actual_len = 0;
|
|
||||||
ret = compressor.compress(src_buf, src_len, dst_buf, dst_buf_len, dst_actual_len, &alloc);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
int64_t alloc_count_bak = alloc.alloc_count_;
|
|
||||||
ASSERT_NE(alloc.alloc_count_, 0);
|
|
||||||
ASSERT_EQ(alloc.free_count_, alloc.alloc_count_);
|
|
||||||
memset(src_buf, 0, src_len);
|
|
||||||
int64_t src_actual_len = 0;
|
|
||||||
ret = compressor.decompress(dst_buf, dst_actual_len, src_buf, src_len, src_actual_len, &alloc);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
ASSERT_EQ(src_actual_len, src_len);
|
|
||||||
ASSERT_EQ(0, memcmp(cmp_buf, src_buf, src_len));
|
|
||||||
ASSERT_GT(alloc.alloc_count_, alloc_count_bak);
|
|
||||||
ASSERT_EQ(alloc.free_count_, alloc.alloc_count_);
|
|
||||||
alloc_count_bak = alloc.alloc_count_;
|
|
||||||
|
|
||||||
// decompress without allocator
|
|
||||||
memset(src_buf, 0, src_len);
|
|
||||||
src_actual_len = 0;
|
|
||||||
ret = compressor.decompress(dst_buf, dst_actual_len, src_buf, src_len, src_actual_len);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
ASSERT_EQ(src_actual_len, src_len);
|
|
||||||
ASSERT_EQ(0, memcmp(cmp_buf, src_buf, src_len));
|
|
||||||
ASSERT_EQ(alloc.alloc_count_, alloc_count_bak);
|
|
||||||
ASSERT_EQ(alloc.free_count_, alloc.alloc_count_);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ObCompressorTest, test_zstd_custom_alloc)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
oceanbase::zstd::ObZstdCompressor compressor;
|
|
||||||
test_zstd_family(compressor);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
oceanbase::zstd_1_3_8::ObZstdCompressor_1_3_8 compressor;
|
|
||||||
test_zstd_family(compressor);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
oceanbase::common::ObLZ4Compressor lz4_compressor;
|
|
||||||
ObCompressor &compressor = lz4_compressor;
|
|
||||||
MyAlloc alloc;
|
|
||||||
ASSERT_EQ(alloc.alloc_count_, 0);
|
|
||||||
ASSERT_EQ(alloc.free_count_, alloc.alloc_count_);
|
|
||||||
int64_t src_len = 2L<<20;
|
|
||||||
char *src_buf = (char*)ob_malloc(src_len, "test");
|
|
||||||
int64_t max_overflow_size = 0;
|
|
||||||
int ret = compressor.get_max_overflow_size(src_len, max_overflow_size);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
int64_t dst_buf_len = src_len + max_overflow_size;
|
|
||||||
char *dst_buf = (char*)ob_malloc(dst_buf_len, "test");
|
|
||||||
int64_t dst_actual_len = 0;
|
|
||||||
ret = compressor.compress(src_buf, src_len, dst_buf, dst_buf_len, dst_actual_len, &alloc);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
ASSERT_EQ(alloc.alloc_count_, 0);
|
|
||||||
int64_t src_actual_len = 0;
|
|
||||||
ret = compressor.decompress(dst_buf, dst_actual_len, src_buf, src_len, src_actual_len, &alloc);
|
|
||||||
ASSERT_EQ(OB_SUCCESS, ret);
|
|
||||||
ASSERT_EQ(alloc.alloc_count_, 0);
|
|
||||||
ASSERT_EQ(src_actual_len, src_len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,6 @@ public:
|
|||||||
void free_log_io_flashback_task(palf::LogIOFlashbackTask *ptr);
|
void free_log_io_flashback_task(palf::LogIOFlashbackTask *ptr);
|
||||||
palf::LogIOPurgeThrottlingTask *alloc_log_io_purge_throttling_task(const int64_t palf_id, const int64_t palf_epoch);
|
palf::LogIOPurgeThrottlingTask *alloc_log_io_purge_throttling_task(const int64_t palf_id, const int64_t palf_epoch);
|
||||||
void free_log_io_purge_throttling_task(palf::LogIOPurgeThrottlingTask *ptr);
|
void free_log_io_purge_throttling_task(palf::LogIOPurgeThrottlingTask *ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t tenant_id_ CACHE_ALIGNED;
|
uint64_t tenant_id_ CACHE_ALIGNED;
|
||||||
int64_t total_limit_;
|
int64_t total_limit_;
|
||||||
|
|||||||
@ -1483,9 +1483,6 @@ int ObOptStatSqlService::get_compressed_llc_bitmap(ObIAllocator &allocator,
|
|||||||
comp_buf = const_cast<char*>(bitmap_buf);
|
comp_buf = const_cast<char*>(bitmap_buf);
|
||||||
comp_size = bitmap_size;
|
comp_size = bitmap_size;
|
||||||
}
|
}
|
||||||
if (compressor != nullptr) {
|
|
||||||
compressor->reset_mem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1527,8 +1524,6 @@ int ObOptStatSqlService::get_decompressed_llc_bitmap(ObIAllocator &allocator,
|
|||||||
LOG_WARN("decompress bitmap buffer failed.",
|
LOG_WARN("decompress bitmap buffer failed.",
|
||||||
KP(comp_buf), K(comp_size), KP(bitmap_buf),
|
KP(comp_buf), K(comp_size), KP(bitmap_buf),
|
||||||
K(max_bitmap_size), K(bitmap_size), K(ret));
|
K(max_bitmap_size), K(bitmap_size), K(ret));
|
||||||
} else {
|
|
||||||
compressor->reset_mem();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ void ObChunkBlockCompressor::reset()
|
|||||||
{
|
{
|
||||||
compressor_type_ = NONE_COMPRESSOR;
|
compressor_type_ = NONE_COMPRESSOR;
|
||||||
if (compressor_ != nullptr) {
|
if (compressor_ != nullptr) {
|
||||||
compressor_->reset_mem();
|
|
||||||
compressor_ = nullptr;
|
compressor_ = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,9 +52,6 @@ ObMicroBlockCompressor::ObMicroBlockCompressor()
|
|||||||
|
|
||||||
ObMicroBlockCompressor::~ObMicroBlockCompressor()
|
ObMicroBlockCompressor::~ObMicroBlockCompressor()
|
||||||
{
|
{
|
||||||
if (compressor_ != nullptr) {
|
|
||||||
compressor_->reset_mem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObMicroBlockCompressor::reset()
|
void ObMicroBlockCompressor::reset()
|
||||||
@ -62,7 +59,6 @@ void ObMicroBlockCompressor::reset()
|
|||||||
is_none_ = false;
|
is_none_ = false;
|
||||||
micro_block_size_ = 0;
|
micro_block_size_ = 0;
|
||||||
if (compressor_ != nullptr) {
|
if (compressor_ != nullptr) {
|
||||||
compressor_->reset_mem();
|
|
||||||
compressor_ = nullptr;
|
compressor_ = nullptr;
|
||||||
}
|
}
|
||||||
comp_buf_.reuse();
|
comp_buf_.reuse();
|
||||||
|
|||||||
@ -55,9 +55,6 @@ ObMacroBlockReader::~ObMacroBlockReader()
|
|||||||
ob_free(encryption_);
|
ob_free(encryption_);
|
||||||
encryption_ = nullptr;
|
encryption_ = nullptr;
|
||||||
}
|
}
|
||||||
if (nullptr != compressor_) {
|
|
||||||
compressor_->reset_mem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OB_BUILD_TDE_SECURITY
|
#ifdef OB_BUILD_TDE_SECURITY
|
||||||
|
|||||||
Reference in New Issue
Block a user