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

Add compile option WITH_PMEM and runtime config enable_pmem #327

Closed
wants to merge 13 commits into from

Conversation

iyupeng
Copy link
Contributor

@iyupeng iyupeng commented Aug 31, 2022

What problem does this PR solve?

Problem Summary: Introducing optional volatile KV storage on DRAM

What is changed and how it works?

What's Changed:

  • add compile option WITH_PMEM, which is ON by default
  • add enable_pmem in KVDK::Configs, which is true by default
  • cmake with -DWITH_PMEM=OFF to remove dependency to libpmem
  • even built with -DWITH_PMEM=ON, setting Configs.enable_pmem = false can make KVDK store data on DRAM

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • None

Signed-off-by: Yu, Peng <peng.yu@intel.com>
@iyupeng iyupeng force-pushed the 2022083101.kvdk_on_general_memory branch from 0eeb1e1 to 4e33e91 Compare August 31, 2022 08:40
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Copy link
Contributor

@ZiyanShi ZiyanShi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split renaming and feature implementation to two pull requests next time. Renaming messes with formatting and makes code hard to review.

std::string AllocatorName() override { return "System"; }

private:
std::atomic<int64_t> bytes_allocated_{0};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bottleneck.
XADD(fetch_add) usually has a maximum Ops at about 20M for multithreading.
Maybe add a TODO for future optimization here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can record usage with thread cache, like in PMEMAllocator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocator gets improved now, supporting multi-threads.

engine/hash_collection/hash_list.cpp Outdated Show resolved Hide resolved
@@ -67,21 +67,27 @@ struct SkiplistNode {
// 4 bytes for alignment, the actually allocated size may > 4
char cached_key[4];

static void DeleteNode(SkiplistNode* node) { free(node->heap_space_start()); }
static void DeleteNode(SkiplistNode* node, Allocator* alloc) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not a good design, as NewNode and DeleteNode should use the same Allocator and such constraint should be enforced by the class. Skiplist class should hold a pointer to the Allocator, although this may bring 8B DRAM cost.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have to call DeleteNode without a Skiplist instance, we may leave a TODO here. Some day we should have different SkiplistFactory to create Skiplist with nodes on DRAM/HBM/CXL mempool and each factory should destroy the skiplists created by it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alloc argument is now removed from these 2 static methods: NewNode() and DeleteNode(). Will try to use an allocator in thread_manager, accessed by thread local data. Here, it also handles cases where the thread_manager is not set.

engine/sorted_collection/skiplist.hpp Outdated Show resolved Hide resolved
engine/write_batch_impl.cpp Show resolved Hide resolved
Signed-off-by: Yu, Peng <peng.yu@intel.com>
engine/data_record.cpp Outdated Show resolved Hide resolved
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
@iyupeng iyupeng force-pushed the 2022083101.kvdk_on_general_memory branch from 7bd6fc0 to b8a93a4 Compare September 1, 2022 03:17
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
Signed-off-by: Yu, Peng <peng.yu@intel.com>
@iyupeng
Copy link
Contributor Author

iyupeng commented Sep 5, 2022

Closing this pull request. It will be split into smaller ones.

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.

None yet

3 participants