Compare commits
4 Commits
11c3ca6766
...
v0.0.9
Author | SHA1 | Date | |
---|---|---|---|
fb9f5ce6f4 | |||
2b1c710953 | |||
ebf281220b | |||
6051b2fb2e |
16
Bench.cpp
16
Bench.cpp
@@ -358,21 +358,6 @@ void benchWorstCaseForRadixRangeRead() {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void benchMetrics() {
|
|
||||||
ankerl::nanobench::Bench bench;
|
|
||||||
ConflictSet cs{0};
|
|
||||||
|
|
||||||
int count;
|
|
||||||
ConflictSet::MetricsV1 *m;
|
|
||||||
cs.getMetricsV1(&m, &count);
|
|
||||||
bench.batch(count);
|
|
||||||
bench.run("fetch metric", [&]() {
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
m[i].getValue();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void benchCreateAndDestroy() {
|
void benchCreateAndDestroy() {
|
||||||
ankerl::nanobench::Bench bench;
|
ankerl::nanobench::Bench bench;
|
||||||
|
|
||||||
@@ -382,6 +367,5 @@ void benchCreateAndDestroy() {
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
benchConflictSet();
|
benchConflictSet();
|
||||||
benchWorstCaseForRadixRangeRead();
|
benchWorstCaseForRadixRangeRead();
|
||||||
benchMetrics();
|
|
||||||
benchCreateAndDestroy();
|
benchCreateAndDestroy();
|
||||||
}
|
}
|
||||||
|
@@ -1111,7 +1111,8 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, WriteContext *tls) {
|
|||||||
memmove(self16->index + i + 1, self16->index + i,
|
memmove(self16->index + i + 1, self16->index + i,
|
||||||
self->numChildren - (i + 1));
|
self->numChildren - (i + 1));
|
||||||
memmove(self16->children + i + 1, self16->children + i,
|
memmove(self16->children + i + 1, self16->children + i,
|
||||||
(self->numChildren - (i + 1)) * sizeof(self16->children[0]));
|
(self->numChildren - (i + 1)) *
|
||||||
|
sizeof(self16->children[0])); // NOLINT
|
||||||
memmove(self16->childMaxVersion + i + 1, self16->childMaxVersion + i,
|
memmove(self16->childMaxVersion + i + 1, self16->childMaxVersion + i,
|
||||||
(self->numChildren - (i + 1)) *
|
(self->numChildren - (i + 1)) *
|
||||||
sizeof(self16->childMaxVersion[0]));
|
sizeof(self16->childMaxVersion[0]));
|
||||||
@@ -3176,6 +3177,11 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addWrites(const WriteRange *writes, int count, int64_t writeVersion) {
|
void addWrites(const WriteRange *writes, int count, int64_t writeVersion) {
|
||||||
|
// There could be other conflict sets in the same thread. We need
|
||||||
|
// InternalVersionT::zero to be correct for this conflict set for the
|
||||||
|
// lifetime of the current call frame.
|
||||||
|
InternalVersionT::zero = oldestVersion;
|
||||||
|
|
||||||
assert(writeVersion >= newestVersionFullPrecision);
|
assert(writeVersion >= newestVersionFullPrecision);
|
||||||
|
|
||||||
if (writeVersion > newestVersionFullPrecision + kNominalVersionWindow) {
|
if (writeVersion > newestVersionFullPrecision + kNominalVersionWindow) {
|
||||||
|
@@ -98,6 +98,13 @@ void ConflictSet::setOldestVersion(int64_t oldestVersion) {
|
|||||||
|
|
||||||
int64_t ConflictSet::getBytes() const { return -1; }
|
int64_t ConflictSet::getBytes() const { return -1; }
|
||||||
|
|
||||||
|
void ConflictSet::getMetricsV1(MetricsV1 **metrics, int *count) const {
|
||||||
|
*metrics = nullptr;
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double ConflictSet::MetricsV1::getValue() const { return 0; }
|
||||||
|
|
||||||
ConflictSet::ConflictSet(int64_t oldestVersion)
|
ConflictSet::ConflictSet(int64_t oldestVersion)
|
||||||
: impl(new(safe_malloc(sizeof(Impl))) Impl{oldestVersion}) {}
|
: impl(new(safe_malloc(sizeof(Impl))) Impl{oldestVersion}) {}
|
||||||
|
|
||||||
|
@@ -56,6 +56,20 @@ def test_conflict_set():
|
|||||||
assert cs.check(read(0, key), read(1, key)) == [Result.TOO_OLD, Result.COMMIT]
|
assert cs.check(read(0, key), read(1, key)) == [Result.TOO_OLD, Result.COMMIT]
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_zero():
|
||||||
|
with DebugConflictSet() as cs1:
|
||||||
|
with DebugConflictSet() as cs2:
|
||||||
|
cs1.addWrites(2, write(b""))
|
||||||
|
cs1.setOldestVersion(2)
|
||||||
|
# "zero" is now 2
|
||||||
|
|
||||||
|
# make a Node48
|
||||||
|
for i in range(256 - 17, 256):
|
||||||
|
cs2.addWrites(int(1), write(bytes([i])))
|
||||||
|
# Scan until first point write
|
||||||
|
cs2.check(read(0, b"\x00", bytes([256 - 17])))
|
||||||
|
|
||||||
|
|
||||||
def test_inner_full_words():
|
def test_inner_full_words():
|
||||||
with DebugConflictSet() as cs:
|
with DebugConflictSet() as cs:
|
||||||
cs.addWrites(1, write(b"\x3f\x61"), write(b"\x81\x61"))
|
cs.addWrites(1, write(b"\x3f\x61"), write(b"\x81\x61"))
|
||||||
|
Reference in New Issue
Block a user