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

perf: support scalable logging #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/ycsb/YcsbWiredTiger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class YcsbWiredTiger : public YcsbExecutor {

std::string configString(
"create, direct_io=[data, log, checkpoint], "
"log=(enabled=true,archive=true), statistics_log=(wait=1), "
"log=(enabled),transaction_sync=(enabled=true,method=none), statistics_log=(wait=1), "
"statistics=(all, clear), session_max=2000, eviction=(threads_max=4), cache_size=" +
std::to_string(FLAGS_ycsb_mem_kb / 1024) + "M");
int ret = wiredtiger_open(dataDir.c_str(), nullptr, configString.c_str(), &mConn);
Expand Down
12 changes: 7 additions & 5 deletions include/leanstore/LeanStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <atomic>
#include <cstdint>
#include <expected>
#include <format>
#include <functional>
#include <memory>
#include <string>
Expand Down Expand Up @@ -52,9 +53,6 @@ class LeanStore {
//! The file descriptor for pages
int32_t mPageFd;

//! The file descriptor for write-ahead log
int32_t mWalFd;

//! The tree registry
std::unique_ptr<storage::TreeRegistry> mTreeRegistry;

Expand Down Expand Up @@ -144,8 +142,8 @@ class LeanStore {
return std::string(mStoreOption->mStoreDir) + "/db.pages";
}

std::string GetWalFilePath() const {
return std::string(mStoreOption->mStoreDir) + "/db.wal";
std::string GetDbWalPath(uint64_t workerId) const {
return std::format("{}/worker_{}.wal", getDbWalDir(), workerId);
}

private:
Expand All @@ -163,6 +161,10 @@ class LeanStore {
void deserializeFlags();

void initPageAndWalFd();

std::string getDbWalDir() const {
return std::format("{}/wal", mStoreOption->mStoreDir);
}
};

} // namespace leanstore
19 changes: 12 additions & 7 deletions include/leanstore/btree/core/PessimisticExclusiveIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "leanstore/KVInterface.hpp"
#include "leanstore/btree/core/PessimisticIterator.hpp"
#include "leanstore/concurrency/WorkerContext.hpp"
#include "leanstore/utils/CounterUtil.hpp"
#include "leanstore/utils/Defer.hpp"
#include "leanstore/utils/Log.hpp"
#include "leanstore/utils/RandomGenerator.hpp"
#include "leanstore/utils/UserThread.hpp"
Expand Down Expand Up @@ -63,7 +65,9 @@ class PessimisticExclusiveIterator : public PessimisticIterator {
}

void SplitForKey(Slice key) {
auto sysTxId = mBTree.mStore->AllocSysTxTs();
TXID sysTxId = cr::WorkerContext::My().StartSysTx();
SCOPED_DEFER(cr::WorkerContext::My().CommitSysTx());

while (true) {
JUMPMU_TRY() {
if (!Valid() || !KeyInCurrentNode(key)) {
Expand Down Expand Up @@ -163,18 +167,18 @@ class PessimisticExclusiveIterator : public PessimisticIterator {

mSlotId = -1;
JUMPMU_TRY() {
TXID sysTxId = mBTree.mStore->AllocSysTxTs();
TXID sysTxId = cr::WorkerContext::My().StartSysTx();
mBTree.TrySplitMayJump(sysTxId, *mGuardedLeaf.mBf, splitSlot);
cr::WorkerContext::My().CommitSysTx();

COUNTER_INC(&leanstore::cr::tlsPerfCounters.mContentionSplitSucceed);
LS_DLOG("[Contention Split] succeed, pageId={}, contention pct={}, split "
"slot={}",
LS_DLOG("[Contention Split] succeed, pageId={}, contentionPct={}, splitSlot={}",
mGuardedLeaf.mBf->mHeader.mPageId, contentionPct, splitSlot);
}
JUMPMU_CATCH() {
COUNTER_INC(&leanstore::cr::tlsPerfCounters.mContentionSplitFailed);
Log::Info("[Contention Split] contention split failed, pageId={}, contention "
"pct={}, split slot={}",
Log::Info("[Contention Split] contention split failed, pageId={}, "
"contentionPct={}, splitSlot={}",
mGuardedLeaf.mBf->mHeader.mPageId, contentionPct, splitSlot);
}
}
Expand All @@ -196,8 +200,9 @@ class PessimisticExclusiveIterator : public PessimisticIterator {
mGuardedLeaf.unlock();
mSlotId = -1;
JUMPMU_TRY() {
TXID sysTxId = mBTree.mStore->AllocSysTxTs();
TXID sysTxId = cr::WorkerContext::My().StartSysTx();
mBTree.TryMergeMayJump(sysTxId, *mGuardedLeaf.mBf);
cr::WorkerContext::My().CommitSysTx();
}
JUMPMU_CATCH() {
LS_DLOG("TryMergeIfNeeded failed, pageId={}", mGuardedLeaf.mBf->mHeader.mPageId);
Expand Down
4 changes: 3 additions & 1 deletion include/leanstore/btree/core/PessimisticIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "leanstore/Slice.hpp"
#include "leanstore/btree/core/BTreeNode.hpp"
#include "leanstore/buffer-manager/GuardedBufferFrame.hpp"
#include "leanstore/concurrency/WorkerContext.hpp"
#include "leanstore/sync/HybridLatch.hpp"
#include "leanstore/utils/Log.hpp"
#include "leanstore/utils/UserThread.hpp"
Expand Down Expand Up @@ -397,8 +398,9 @@ inline void PessimisticIterator::Next() {
if (mGuardedLeaf->mNumSlots == 0) {
SetCleanUpCallback([&, toMerge = mGuardedLeaf.mBf]() {
JUMPMU_TRY() {
TXID sysTxId = mBTree.mStore->AllocSysTxTs();
TXID sysTxId = cr::WorkerContext::My().StartSysTx();
mBTree.TryMergeMayJump(sysTxId, *toMerge, true);
cr::WorkerContext::My().CommitSysTx();
}
JUMPMU_CATCH() {
}
Expand Down
7 changes: 2 additions & 5 deletions include/leanstore/buffer-manager/GuardedBufferFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ class GuardedBufferFrame {

// update system transaction id
mBf->mPage.mSysTxId = sysTxId;

// update the maximum system transaction id written by the worker
cr::WorkerContext::My().mLogging.UpdateSysTxWrittern(sysTxId);
}

//! Check remote dependency
Expand All @@ -172,8 +169,8 @@ class GuardedBufferFrame {
}

if (mBf->mHeader.mLastWriterWorker != cr::WorkerContext::My().mWorkerId &&
mBf->mPage.mSysTxId > cr::ActiveTx().mMaxObservedSysTxId) {
cr::ActiveTx().mMaxObservedSysTxId = mBf->mPage.mSysTxId;
mBf->mPage.mSysTxId > cr::ActiveTx().mDependentSysTx) {
cr::ActiveTx().mDependentSysTx = mBf->mPage.mSysTxId;
cr::ActiveTx().mHasRemoteDependency = true;
}
}
Expand Down
11 changes: 2 additions & 9 deletions include/leanstore/concurrency/CRManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class LeanStore;
namespace cr {

struct WaterMarkInfo;
class GroupCommitter;

//! Manages a fixed number of worker threads and group committer threads.
class CRManager {
Expand All @@ -30,19 +29,13 @@ class CRManager {

WaterMarkInfo mGlobalWmkInfo;

//! The group committer thread, created and started if WAL is enabled when the
//! CRManager instance is created.
///
//! NOTE: It should be created after all the worker threads are created and
//! started.
std::unique_ptr<GroupCommitter> mGroupCommitter;

public:
//! Construct a CRManager.
CRManager(leanstore::LeanStore* store);

//! Destruct a CRManager.
~CRManager();

public:
// State Serialization
StringMap Serialize();

Expand Down
94 changes: 0 additions & 94 deletions include/leanstore/concurrency/GroupCommitter.hpp

This file was deleted.

Loading
Loading