Applying most of nio's comments.
Defaulting to redwood in SimulatedCluster.actor.cpp for simulation testing. New code passed > 100 correctness tests
This commit is contained in:
parent
59eede009c
commit
098be3a581
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* ArtMutationBuffer.h
|
||||
*
|
||||
* This source file is part of the FoundationDB open source project
|
||||
*
|
||||
* Copyright 2013-2020 Apple Inc. and the FoundationDB project authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ART_MUTATION_BUFFER
|
||||
#define ART_MUTATION_BUFFER
|
||||
|
||||
|
@ -89,7 +108,6 @@ public:
|
|||
};
|
||||
|
||||
MutationBuffer() {
|
||||
printf("NEW MB\n");
|
||||
mutations = new(arena) art_tree(arena);
|
||||
// Create range representing the entire keyspace. This reduces edge cases to applying mutations
|
||||
// because now all existing keys are within some range in the mutation map.
|
||||
|
@ -161,9 +179,8 @@ public:
|
|||
iterator ib = iterator(mutations->insert_if_absent(boundary, nullptr, &already_present));
|
||||
if (already_present) {
|
||||
return ib;
|
||||
} else {
|
||||
*(ib.value_ptr()) = new(arena) RangeMutation();
|
||||
}
|
||||
*(ib.value_ptr()) = new(arena) RangeMutation();
|
||||
iterator iPrevious = ib;
|
||||
--iPrevious;
|
||||
if (iPrevious.mutation().clearAfterBoundary) {
|
||||
|
|
|
@ -737,7 +737,7 @@ void SimulationConfig::generateNormalConfig(int minimumReplication, int minimumR
|
|||
if (deterministicRandom()->random01() < 0.25) db.desiredTLogCount = deterministicRandom()->randomInt(1,7);
|
||||
if (deterministicRandom()->random01() < 0.25) db.masterProxyCount = deterministicRandom()->randomInt(1,7);
|
||||
if (deterministicRandom()->random01() < 0.25) db.resolverCount = deterministicRandom()->randomInt(1,7);
|
||||
int storage_engine_type = deterministicRandom()->randomInt(0, 3);
|
||||
int storage_engine_type = 3;//deterministicRandom()->randomInt(0, 3);
|
||||
switch (storage_engine_type) {
|
||||
case 0: {
|
||||
TEST(true); // Simulated cluster using ssd storage engine
|
||||
|
@ -754,6 +754,11 @@ void SimulationConfig::generateNormalConfig(int minimumReplication, int minimumR
|
|||
set_config("memory-radixtree-beta");
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
TEST(true); // Simulated cluster using radix-tree storage engine
|
||||
set_config("ssd-redwood-experimental");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ASSERT(false); // Programmer forgot to adjust cases.
|
||||
}
|
||||
|
|
|
@ -74,17 +74,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
struct art_iterator;
|
||||
|
||||
struct art_tree {
|
||||
|
||||
|
||||
#define ART_LEAF 0
|
||||
#define ART_NODE4 1
|
||||
#define ART_NODE16 2
|
||||
#define ART_NODE48 3
|
||||
#define ART_NODE256 4
|
||||
#define ART_NODE4_KV 5
|
||||
#define ART_NODE16_KV 6
|
||||
#define ART_NODE48_KV 7
|
||||
#define ART_NODE256_KV 8
|
||||
enum ART_NODE_TYPE : uint8_t{
|
||||
ART_LEAF = 0, ART_NODE4 = 1, ART_NODE16 = 2, ART_NODE48 = 3, ART_NODE256 = 4,
|
||||
ART_NODE4_KV = 5, ART_NODE16_KV = 6, ART_NODE48_KV = 7, ART_NODE256_KV = 8
|
||||
};
|
||||
#define ART_MIN_LEAF_UNSET 1UL
|
||||
#define ART_LEAF_MATCH_KEY 1
|
||||
#define ART_LEAF_SMALLER_KEY 2
|
||||
|
@ -98,7 +91,7 @@ struct art_tree {
|
|||
#define ART_NEITHER 0
|
||||
|
||||
|
||||
#define ART_IS_LEAF(x) ( (*((uint8_t*)x) == ART_LEAF))
|
||||
#define ART_IS_LEAF(x) ( (*((ART_NODE_TYPE*)x) == ART_LEAF))
|
||||
|
||||
#define ART_LEAF_RAW(x) ((art_leaf*)(x))
|
||||
|
||||
|
@ -127,7 +120,7 @@ struct art_tree {
|
|||
* of all the various node sizes
|
||||
*/
|
||||
struct art_node {
|
||||
uint8_t type;
|
||||
ART_NODE_TYPE type;
|
||||
uint8_t num_children;
|
||||
uint32_t partial_len;
|
||||
unsigned char partial[ART_MAX_PREFIX_LEN];
|
||||
|
@ -139,7 +132,7 @@ struct art_tree {
|
|||
* Note that the first two fields must be the same as in art_node
|
||||
*/
|
||||
struct art_leaf {
|
||||
uint8_t type;
|
||||
ART_NODE_TYPE type;
|
||||
void *value;
|
||||
art_leaf *prev = nullptr;
|
||||
art_leaf *next = nullptr;
|
||||
|
@ -229,16 +222,6 @@ struct art_tree {
|
|||
art_leaf *leaf;
|
||||
};
|
||||
|
||||
struct art_children_pair {
|
||||
art_node *child = nullptr;
|
||||
art_node *next = nullptr;
|
||||
art_node *prev = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Main struct, points to root.
|
||||
*/
|
||||
|
||||
|
||||
private:
|
||||
art_node *root;
|
||||
|
@ -265,7 +248,6 @@ private:
|
|||
|
||||
static art_leaf *minimum_kv(art_node *n);
|
||||
|
||||
|
||||
static art_node **find_child(art_node *n, unsigned char c);
|
||||
|
||||
static void find_next(art_node *n, unsigned char c, art_node **out);
|
||||
|
@ -292,9 +274,9 @@ private:
|
|||
void remove_child(art_node *n, art_node **ref, unsigned char c, art_node **l, int depth);
|
||||
|
||||
//needs this pointer to do allocation
|
||||
art_node *alloc_node(uint8_t type);
|
||||
art_node *alloc_node(ART_NODE_TYPE type);
|
||||
|
||||
art_node *alloc_kv_node(uint8_t type);
|
||||
art_node *alloc_kv_node(ART_NODE_TYPE type);
|
||||
|
||||
art_leaf *make_leaf(const KeyRef &k, void *value);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* art.h
|
||||
* art_impl.h
|
||||
*
|
||||
* This source file is part of the FoundationDB open source project
|
||||
*
|
||||
|
@ -52,10 +52,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef ART_IMPL_H
|
||||
#define ART_IMPL_H
|
||||
|
||||
#define art_tree VersionedBTree::art_tree
|
||||
|
||||
//#define art_tree VersionedBTree::art_tree
|
||||
using art_tree = VersionedBTree::art_tree;
|
||||
#define art_node art_tree::art_node
|
||||
|
||||
typedef art_tree::art_leaf art_leaf;
|
||||
//typedef art_tree::art_leaf art_leaf;
|
||||
using art_leaf = art_tree::art_leaf;
|
||||
|
||||
|
||||
int art_tree::fat_leaf_offset[] = {
|
||||
|
@ -149,6 +152,7 @@ art_leaf *art_tree::minimum(art_node *n) {
|
|||
case ART_NODE4_KV:
|
||||
return ART_FAT_NODE_LEAF(n);
|
||||
default:
|
||||
printf("%d\n", n->type);
|
||||
UNSTOPPABLE_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
@ -1158,7 +1162,7 @@ art_leaf *art_tree::insert_fat_node(art_node *n, art_node **ref, const KeyRef &k
|
|||
art_leaf *lm = min_of_n == nullptr ? minimum(n) : min_of_n; //FIXME: reuse from before if already taken
|
||||
art_node *nkv = n;
|
||||
//change the type before deferencing the leaf
|
||||
nkv->type = n->type + 4;
|
||||
nkv->type = static_cast<ART_NODE_TYPE>(n->type + 4);
|
||||
art_leaf *l_new = make_leaf(k, value);
|
||||
ART_FAT_NODE_LEAF(nkv) = l_new;
|
||||
*ref = (art_node *) nkv;
|
||||
|
@ -1445,15 +1449,17 @@ void art_tree::add_child4(art_node4 *n, art_node **ref, unsigned char c, void *c
|
|||
|
||||
|
||||
//Every node is actually a kv node, but the type is <= NODE256
|
||||
art_node *art_tree::alloc_node(uint8_t type) {
|
||||
art_node *art_tree::alloc_node(ART_NODE_TYPE type) {
|
||||
const int offset = type > ART_NODE256 ? 0 : ART_NODE256;
|
||||
art_node *n = (art_node *) new((Arena & ) * this->arena)uint8_t[node_sizes[offset + type]]();
|
||||
art_node *n = (art_node *)
|
||||
new((Arena & ) * this->arena)uint8_t[node_sizes[offset + type]]();
|
||||
n->type = type;
|
||||
return n;
|
||||
}
|
||||
|
||||
art_node *art_tree::alloc_kv_node(uint8_t type) {
|
||||
art_node *n = (art_node *) new((Arena & ) * this->arena)uint8_t[node_sizes[type]]();
|
||||
art_node *art_tree::alloc_kv_node(ART_NODE_TYPE type) {
|
||||
art_node *n = (art_node *)
|
||||
new((Arena & ) * this->arena)uint8_t[node_sizes[type]]();
|
||||
n->type = type;
|
||||
return n;
|
||||
}
|
||||
|
@ -1461,7 +1467,8 @@ art_node *art_tree::alloc_kv_node(uint8_t type) {
|
|||
art_leaf *art_tree::make_leaf(const KeyRef &k, void *value) {
|
||||
const int key_len = k.size();
|
||||
//Allocate contiguous buffer to hold the leaf and the key pointed by the KeyRef
|
||||
art_leaf *v = (art_leaf *) new((Arena & ) * this->arena)uint8_t[sizeof(art_leaf) + key_len];
|
||||
art_leaf *v = (art_leaf *)
|
||||
new((Arena & ) * this->arena)uint8_t[sizeof(art_leaf) + key_len];
|
||||
//copy the key to the proper offset in the buffer
|
||||
memcpy(v + 1, k.begin(), key_len);
|
||||
KeyRef nkr = KeyRef((const uint8_t *) (v + 1), key_len);
|
||||
|
|
Loading…
Reference in New Issue