8000 Removed MemoryPool and RecyclePool by yuzhichang · Pull Request #1248 · infiniflow/infinity · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Removed MemoryPool and RecyclePool #1248

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

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
10000
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/default_values.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export {
constexpr SizeT DEFAULT_BASE_FILE_SIZE = 8 * 1024;
constexpr SizeT DEFAULT_OUTLINE_FILE_MAX_SIZE = 16 * 1024 * 1024;

constexpr SizeT DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;
constexpr SizeT DEFAULT_ALIGN_SIZE = sizeof(char *);

constexpr SizeT MIN_CLEANUP_INTERVAL_SEC = 0; // 0 means disable the function
constexpr SizeT DEFAULT_CLEANUP_INTERVAL_SEC = 10;
constexpr std::string_view DEFAULT_CLEANUP_INTERVAL_SEC_STR = "10s"; // 10 seconds
Expand Down
25 changes: 8 additions & 17 deletions src/common/memory/byte_slice.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
module;

import memory_pool;
import stl;

module byte_slice;

namespace infinity {

ByteSlice *ByteSlice::CreateSlice(SizeT data_size, MemoryPool *pool) {
ByteSlice *ByteSlice::CreateSlice(SizeT data_size) {
u8 *mem;
SizeT mem_size = data_size + GetHeadSize();
if (pool == nullptr) {
mem = new u8[mem_size];
} else {
mem = (u8 *)pool->Allocate(mem_size);
}
mem = new u8[mem_size];
ByteSlice *slice = new (mem) ByteSlice;
slice->data_ = mem + GetHeadSize();
slice->size_ = data_size;
Expand All @@ -32,14 +27,10 @@ ByteSlice *ByteSlice::NewSlice(u8 *data, SizeT data_size) {
return slice;
}

void ByteSlice::DestroySlice(ByteSlice *slice, MemoryPool *pool) {
void ByteSlice::DestroySlice(ByteSlice *slice) {
u8 *mem = (u8 *)slice;
if (slice->owned_) {
if (pool == nullptr) {
delete[] mem;
} else {
pool->Deallocate(mem, slice->size_ + GetHeadSize());
}
delete[] mem;
} else {
delete slice;
}
Expand All @@ -51,13 +42,13 @@ ByteSliceList::ByteSliceList() {
total_size_ = 0;
}

ByteSliceList::ByteSliceList(ByteSlice *slice, MemoryPool *pool) : head_(nullptr), tail_(nullptr), total_size_(0), pool_(pool) {
ByteSliceList::ByteSliceList(ByteSlice *slice) : head_(nullptr), tail_(nullptr), total_size_(0) {
if (slice != nullptr) {
Add(slice);
}
}

ByteSliceList::~ByteSliceList() { Clear(pool_); }
ByteSliceList::~ByteSliceList() { Clear(); }

void ByteSliceList::Add(ByteSlice *slice) {
if (tail_ == nullptr) {
Expand All @@ -69,13 +60,13 @@ void ByteSliceList::Add(ByteSlice *slice) {
total_size_ = total_size_ + slice->size_;
}

void ByteSliceList::Clear(MemoryPool *pool) {
void ByteSliceList::Clear() {
ByteSlice *slice = head_;
ByteSlice *next = nullptr;

while (slice) {
next = slice->next_;
ByteSlice::DestroySlice(slice, pool);
ByteSlice::DestroySlice(slice);
slice = next;
}

Expand Down
11 changes: 5 additions & 6 deletions src/common/memory/byte_slice.cppm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module;

import stl;
import memory_pool;


export module byte_slice;

Expand All @@ -18,11 +18,11 @@ export struct ByteSlice {

static constexpr SizeT GetHeadSize() { return sizeof(ByteSlice); }

static ByteSlice *CreateSlice(SizeT data_size, MemoryPool *pool = nullptr);
static ByteSlice *CreateSlice(SizeT data_size);

static ByteSlice *NewSlice(u8 *data, SizeT data_size);

static void DestroySlice(ByteSlice *slice, MemoryPool *pool = nullptr);
static void DestroySlice(ByteSlice *slice);

static ByteSlice *GetEmptySlice() {
static ByteSlice slice;
Expand All @@ -42,7 +42,7 @@ export class ByteSliceList {
public:
ByteSliceList();

ByteSliceList(ByteSlice *slice, MemoryPool *pool = nullptr);
ByteSliceList(ByteSlice *slice);

virtual ~ByteSliceList();

Expand All @@ -59,13 +59,12 @@ public:

void MergeWith(ByteSliceList &other);

virtual void Clear(MemoryPool *pool);
virtual void Clear();

private:
ByteSlice *head_;
ByteSlice *tail_;
SizeT volatile total_size_;
MemoryPool *pool_{nullptr};
};

export class ByteSliceListIterator {
Expand Down
104 changes: 0 additions & 104 deletions src/common/memory/memory_pool.cpp

This file was deleted.

144 changes: 0 additions & 144 deletions src/common/memory/memory_pool.cppm

This file was deleted.

Loading
Loading
0