Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Apr 2, 2023
1 parent 8a9b70d commit 00c32cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
13 changes: 2 additions & 11 deletions src/include/storage/buffer_manager/buffer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,10 @@ class EvictionQueue {
std::shared_lock sLck{mtx};
return queue->try_dequeue(candidate);
}

void removeNonEvictableCandidates();

inline void removeCandidatesForFile(BMFileHandle& fileHandle) {
std::unique_lock xLck{mtx};
EvictionCandidate candidate;
uint64_t loopCandidateIdx = 0;
while (loopCandidateIdx < capacity && queue->try_dequeue(candidate)) {
if (candidate.fileHandle != &fileHandle) {
queue->enqueue(candidate);
}
loopCandidateIdx++;
}
}
void removeCandidatesForFile(BMFileHandle& fileHandle);

private:
std::shared_mutex mtx;
Expand Down
22 changes: 20 additions & 2 deletions src/storage/buffer_manager/buffer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "common/exception.h"
#include "spdlog/spdlog.h"

#include <iostream>

using namespace kuzu::common;

namespace kuzu {
Expand Down Expand Up @@ -43,16 +45,32 @@ void EvictionQueue::removeNonEvictableCandidates() {
}
}

void EvictionQueue::removeCandidatesForFile(kuzu::storage::BMFileHandle &fileHandle) {
std::unique_lock xLck{mtx};
EvictionCandidate candidate;
uint64_t loopedCandidateIdx = 0;
auto numCandidatesInQueue = queue->size_approx();
while (loopedCandidateIdx < numCandidatesInQueue && queue->try_dequeue(candidate)) {
if (candidate.fileHandle != &fileHandle) {
queue->enqueue(candidate);
}
loopedCandidateIdx++;
}
}

BufferManager::BufferManager(uint64_t bufferPoolSize)
: logger{LoggerUtils::getLogger(common::LoggerConstants::LoggerEnum::BUFFER_MANAGER)},
usedMemory{0}, bufferPoolSize{bufferPoolSize}, numEvictionQueueInsertions{0} {
logger->info("Done initializing buffer manager.");
auto num4KBPagesInBM = bufferPoolSize / BufferPoolConstants::PAGE_4KB_SIZE;
if (num4KBPagesInBM < 1) {
throw BufferManagerException("The given buffer pool size should be at least 4KB.");
}
vmRegions.resize(2);
vmRegions[0] = std::make_unique<VMRegion>(
PageSizeClass::PAGE_4KB, BufferPoolConstants::DEFAULT_VM_REGION_MAX_SIZE);
vmRegions[1] = std::make_unique<VMRegion>(PageSizeClass::PAGE_256KB, bufferPoolSize);
evictionQueue =
std::make_unique<EvictionQueue>(bufferPoolSize / BufferPoolConstants::PAGE_4KB_SIZE);
evictionQueue = std::make_unique<EvictionQueue>(num4KBPagesInBM);
}

// Important Note: Pin returns a raw pointer to the frame. This is potentially very dangerous and
Expand Down
1 change: 0 additions & 1 deletion tools/python_api/test/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_to_arrow_complex(establish_connection):
conn, db = establish_connection

def _test_node(_conn):
# query = "MATCH (a:person) RETURN a.ID, a.fName, a.gender, a.isStudent, a.isWorker, a.age, a.eyeSight, a.birthdate, a.registerTime, a.lastJobDuration, a.workedHours, a.usedNames, a.courseScoresPerTerm ORDER BY a.ID;"
query = "MATCH (p:person) RETURN p ORDER BY p.ID"
query_result = _conn.execute(query)
arrow_tbl = query_result.get_as_arrow(12)
Expand Down

0 comments on commit 00c32cc

Please sign in to comment.