From ef3595d09bd96ac2fb9c2e1135abc6d91d824eb5 Mon Sep 17 00:00:00 2001 From: William Brown Date: Mar 09 2017 00:16:00 +0000 Subject: Ticket 49160 - Fix sds benchmark and copyright Bug Description: THe sds code had the incorrect copyright, and the benchmark did not work with the new i686 fixes Fix Description: Fix the copyright to redhat and fix the test to use uint64_t pointers. https://pagure.io/389-ds-base/issue/49160 Author: wibrown Review by: mreynolds (Thanks) --- diff --git a/src/libsds/include/sds.h b/src/libsds/include/sds.h index 31507a7..1b0dede 100644 --- a/src/libsds/include/sds.h +++ b/src/libsds/include/sds.h @@ -1,8 +1,9 @@ /* BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -394,39 +395,58 @@ typedef struct _sds_bptree_transaction { * in the B+Tree and COW B+Tree. A signifigant amount of testing went into the * tuning of this value for best performance. */ -#define SDS_BPTREE_DEFAULT_CAPACITY 5 +#define SDS_BPTREE_DEFAULT_CAPACITY 3 /** * SDS_BPTREE_HALF_CAPACITY 3 is pre-calculated as "ceiling(default capacity / 2)". * This is used to assert when node splits and merges should be taken. */ -#define SDS_BPTREE_HALF_CAPACITY 3 +#define SDS_BPTREE_HALF_CAPACITY 2 /** * SDS_BPTREE_BRANCH 6 indicates that each node may potentially have up to 6 child * nodes. This yields a broad tree, that requires fewer cache misses to travese * (despite the higher number of comparisons to search). */ -#define SDS_BPTREE_BRANCH 6 +#define SDS_BPTREE_BRANCH 4 /** * This is the core of the B+Tree structures. This node represents the branches - * and leaves of the structure. It is 128 bytes, which fits on two cachelines. - * Thanks to modern prediction strategies, this is faster than a 64 byte struct - *, and yields the best performance in real tests. + * and leaves of the structure. */ typedef struct _sds_bptree_node { +#ifdef DEBUG /** - * checksum of the structure data to detect errors. + * checksum of the structure data to detect errors. Must be the first element + * in the struct. */ uint32_t checksum; +#endif + /** + * Statically sized array of pointers to the keys of this structure. + */ + void *keys[SDS_BPTREE_DEFAULT_CAPACITY]; + /** + * Statically sized array of pointers to values. This is tagged by the level + * flag. If level is 0, this is a set of values that have been inserted + * by the consumer. If the level is > 0, this is the pointers to further + * node structs. + * + * In a leaf, this is [value, value, value, value, value, link -> ] + * + * In a non-leaf, this is [link, link, link, link, link, link] + */ + void *values[SDS_BPTREE_BRANCH]; /** * The number of values currently stored in this structure. */ - uint16_t item_count; + uint32_t item_count; /** * This number of "rows" above the leaves this node is. 0 represents a true * leaf node, anything greater is a branch. */ - uint64_t level; + uint32_t level; + /* Put these last because they are only used in the insert / delete path, not the search. + * This way the keys and values are always in the cache associated with the ptr. + */ /** * The id of the transaction that created this node. This is used so that * within a transaction, we don't double copy values if we already copied @@ -438,21 +458,6 @@ typedef struct _sds_bptree_node { * list during each insertion (by a large factor). */ struct _sds_bptree_node *parent; - /** - * Statically sized array of pointers to the keys of this structure. - */ - void *keys[SDS_BPTREE_DEFAULT_CAPACITY]; - /** - * Statically sized array of pointers to values. This is tagged by the level - * flag. If level is 0, this is a set of values that have been inserted - * by the consumer. If the level is > 0, this is the pointers to further - * node structs. - * - * In a leaf, this is [value, value, value, value, value, link -> ] - * - * In a non-leaf, this is [link, link, link, link, link, link] - */ - void *values[SDS_BPTREE_BRANCH]; } sds_bptree_node; /** diff --git a/src/libsds/sds/bpt/bpt.c b/src/libsds/sds/bpt/bpt.c index e20d0c5..6756ef0 100644 --- a/src/libsds/sds/bpt/bpt.c +++ b/src/libsds/sds/bpt/bpt.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt/bpt.h b/src/libsds/sds/bpt/bpt.h index 6c429f7..712213b 100644 --- a/src/libsds/sds/bpt/bpt.h +++ b/src/libsds/sds/bpt/bpt.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt/common.c b/src/libsds/sds/bpt/common.c index 05b748e..dcfecae 100644 --- a/src/libsds/sds/bpt/common.c +++ b/src/libsds/sds/bpt/common.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -20,7 +21,7 @@ sds_bptree_node_create() { node->txn_id = 0; #ifdef DEBUG - printf("sds_bptree_node_create: Creating node_%p item_count=%d\n", node, node->item_count); + sds_log("sds_bptree_node_create", "Creating node_%p item_count=%d\n", node, node->item_count); #endif return node; @@ -97,7 +98,7 @@ sds_bptree_node_node_index(sds_bptree_node *parent, sds_bptree_node *child) { void sds_bptree_node_node_replace(sds_bptree_node *target_node, sds_bptree_node *origin_node, sds_bptree_node *replace_node) { #ifdef DEBUG - printf("sds_bptree_node_node_replace: Replace node_%p to overwrite node_%p in node_%p\n", origin_node, replace_node, target_node); + sds_log("sds_bptree_node_node_replace", "Replace node_%p to overwrite node_%p in node_%p\n", origin_node, replace_node, target_node); #endif size_t index = sds_bptree_node_node_index(target_node, origin_node); target_node->values[index] = replace_node; @@ -468,7 +469,12 @@ sds_bptree_root_insert(sds_bptree_instance *binst, sds_bptree_node *left_node, s sds_log("sds_bptree_root_insert", "left_node %p, key %d, right_node %p", left_node, key, right_node); #endif sds_bptree_node *root_node = sds_bptree_node_create(); - root_node->level = left_node->level + 1; + /* On non debug, we only need to know if this is a leaf or not. */ + if (left_node->level == 0) { + root_node->level = 1; + } else { + root_node->level = left_node->level; + } /* Is already duplicated */ root_node->keys[0] = key; diff --git a/src/libsds/sds/bpt/list.c b/src/libsds/sds/bpt/list.c index de7c9b3..b89aed6 100644 --- a/src/libsds/sds/bpt/list.c +++ b/src/libsds/sds/bpt/list.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt/map.c b/src/libsds/sds/bpt/map.c index 4205aa5..4ba340e 100644 --- a/src/libsds/sds/bpt/map.c +++ b/src/libsds/sds/bpt/map.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -90,7 +91,7 @@ sds_bptree_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) { for (size_t i = 0; i < node->item_count; i++) { if (node->keys[i] == NULL) { - printf("%d \n", node->item_count); + sds_log("sds_bptree_verify_node", "%d \n", node->item_count); return SDS_INVALID_KEY; } @@ -286,7 +287,7 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n return SDS_INVALID_NODE; } // Given the node write it out as: - fprintf(fp, "subgraph c%"PRIu64" { \n rank=\"same\";\n", node->level); + fprintf(fp, "subgraph c%"PRIu32" { \n rank=\"same\";\n", node->level); fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%"PRIu64" parent=%p | { ", node, node, node->item_count, node->txn_id, node->parent ); for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { fprintf(fp, "| %" PRIu64 " | ", (uint64_t)node->keys[i], i + 1 ); diff --git a/src/libsds/sds/bpt/search.c b/src/libsds/sds/bpt/search.c index f406bcc..e60f259 100644 --- a/src/libsds/sds/bpt/search.c +++ b/src/libsds/sds/bpt/search.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt/set.c b/src/libsds/sds/bpt/set.c index 50f4426..2319ac4 100644 --- a/src/libsds/sds/bpt/set.c +++ b/src/libsds/sds/bpt/set.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt/verify.c b/src/libsds/sds/bpt/verify.c index b9ddc12..085083a 100644 --- a/src/libsds/sds/bpt/verify.c +++ b/src/libsds/sds/bpt/verify.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/atomic.c b/src/libsds/sds/bpt_cow/atomic.c index 63bb645..e4dbe4f 100644 --- a/src/libsds/sds/bpt_cow/atomic.c +++ b/src/libsds/sds/bpt_cow/atomic.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/bpt_cow.c b/src/libsds/sds/bpt_cow/bpt_cow.c index 1489239..7bcf030 100644 --- a/src/libsds/sds/bpt_cow/bpt_cow.c +++ b/src/libsds/sds/bpt_cow/bpt_cow.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -511,7 +512,7 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n return SDS_INVALID_NODE; } // Given the node write it out as: - fprintf(fp, "subgraph c%"PRIu64" { \n rank=\"same\";\n", node->level); + fprintf(fp, "subgraph c%"PRIu32" { \n rank=\"same\";\n", node->level); fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%"PRIu64" parent=%p | { ", node, node, node->item_count, node->txn_id, node->parent ); for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { fprintf(fp, "| %" PRIu64 " | ", (uint64_t)node->keys[i], i + 1 ); diff --git a/src/libsds/sds/bpt_cow/bpt_cow.h b/src/libsds/sds/bpt_cow/bpt_cow.h index 4c0adc0..00c8f77 100644 --- a/src/libsds/sds/bpt_cow/bpt_cow.h +++ b/src/libsds/sds/bpt_cow/bpt_cow.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/delete.c b/src/libsds/sds/bpt_cow/delete.c index d39a836..32307f8 100644 --- a/src/libsds/sds/bpt_cow/delete.c +++ b/src/libsds/sds/bpt_cow/delete.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/insert.c b/src/libsds/sds/bpt_cow/insert.c index 912ab0a..4fe9eff 100644 --- a/src/libsds/sds/bpt_cow/insert.c +++ b/src/libsds/sds/bpt_cow/insert.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -16,10 +17,11 @@ sds_bptree_cow_root_insert(sds_bptree_transaction *btxn, sds_bptree_node *left_n #endif // Just make the new root, add the nodes, and update the root in the txn. sds_bptree_node *root_node = sds_bptree_cow_node_create(btxn); - root_node->level = left_node->level + 1; -#ifdef DEBUG - sds_log("sds_bptree_cow_root_insert", "New root level %d", root_node->level); -#endif + if (left_node->level == 0) { + root_node->level = 1; + } else { + root_node->level = left_node->level; + } root_node->keys[0] = key; root_node->values[0] = (void *)left_node; root_node->values[1] = (void *)right_node; diff --git a/src/libsds/sds/bpt_cow/node.c b/src/libsds/sds/bpt_cow/node.c index 3fec40b..648f6ea 100644 --- a/src/libsds/sds/bpt_cow/node.c +++ b/src/libsds/sds/bpt_cow/node.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -10,17 +11,10 @@ #ifdef DEBUG static sds_result -sds_bptree_cow_node_path_verify(sds_bptree_transaction *btxn, sds_bptree_node *old_node, sds_bptree_node *node) { +sds_bptree_cow_node_path_verify(sds_bptree_transaction *btxn, sds_bptree_node *node) { // Verify that the node has a valid parent path back to the root! - sds_bptree_node *boom = NULL; - uint64_t level = old_node->level; sds_bptree_node *target_node = node; while (target_node->parent != NULL) { - if (target_node->level != level) { - sds_log("sds_bptree_cow_node_path_verify", "node_%p should be level %d, is %d", target_node, level, target_node->level); - boom->level = 0xffffffff; - } - level = level + 1; target_node = target_node->parent; } if (btxn->root != target_node) { @@ -84,8 +78,8 @@ sds_bptree_cow_node_clone(sds_bptree_transaction *btxn, sds_bptree_node *node) { sds_bptree_node_list_push(&(btxn->created), clone_node); #ifdef DEBUG - printf("sds_bptree_cow_node_clone: Cloning node_%p item_count=%d --> clone node_%p\n", node, node->item_count, clone_node); - printf("sds_bptree_cow_node_clone: txn_%p tentatively owns node_%p for cleaning\n", btxn->parent_txn, node); + sds_log("sds_bptree_cow_node_clone", "Cloning node_%p item_count=%d --> clone node_%p\n", node, node->item_count, clone_node); + sds_log("sds_bptree_cow_node_clone", "txn_%p tentatively owns node_%p for cleaning\n", btxn->parent_txn, node); #endif return clone_node; @@ -109,7 +103,7 @@ static void sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origin_node, sds_bptree_node *clone_node) { #ifdef DEBUG - printf("sds_bptree_cow_branch_clone: Cloning branch from node_%p\n", clone_node); + sds_log("sds_bptree_cow_branch_clone", "Cloning branch from node_%p\n", clone_node); #endif // Right, we have now cloned the node. We need to walk up the tree and clone // all the branches that path to us. @@ -129,7 +123,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi // TODO: This probably needs to update csums of the nodes along the branch. #ifdef DEBUG - printf("sds_bptree_cow_branch_clone: Branch parent node_%p already within txn, finishing...\n", parent_node); + sds_log("sds_bptree_cow_branch_clone", "Branch parent node_%p already within txn, finishing...\n", parent_node); if (btxn->bi->offline_checksumming) { // Update this becuase we are updating the owned node lists. sds_bptree_crc32c_update_node(parent_node); @@ -141,7 +135,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi // Is the parent node NOT in this txn? // We need to clone the parent, and then replace ourselves in it .... #ifdef DEBUG - printf("sds_bptree_cow_branch_clone: Branch parent node_%p NOT within txn, cloning...\n", parent_node); + sds_log("sds_bptree_cow_branch_clone", "Branch parent node_%p NOT within txn, cloning...\n", parent_node); #endif // This is actually the important part! parent_clone_node = sds_bptree_cow_node_clone(btxn, parent_node); @@ -167,7 +161,7 @@ sds_bptree_cow_branch_clone(sds_bptree_transaction *btxn, sds_bptree_node *origi // We have hit the root, update the root. // Origin is root, update the txn root. #ifdef DEBUG - printf("sds_bptree_cow_branch_clone: Updating txn_%p root from node_%p to node_%p\n", btxn, btxn->root, former_clone_node); + sds_log("sds_bptree_cow_branch_clone", "Updating txn_%p root from node_%p to node_%p\n", btxn, btxn->root, former_clone_node); #endif btxn->root = former_clone_node; } @@ -201,7 +195,7 @@ sds_bptree_cow_node_prepare(sds_bptree_transaction *btxn, sds_bptree_node *node) result_node = clone_node; } #ifdef DEBUG - if (sds_bptree_cow_node_path_verify(btxn, node, result_node)!= SDS_SUCCESS) { + if (sds_bptree_cow_node_path_verify(btxn, result_node)!= SDS_SUCCESS) { sds_log("sds_bptree_cow_node_prepare", "!!! Invalid path from cow_node to root!"); return NULL; } @@ -216,7 +210,8 @@ sds_bptree_cow_node_create(sds_bptree_transaction *btxn) { sds_bptree_node *node = sds_memalign(sizeof(sds_bptree_node), SDS_CACHE_ALIGNMENT); // Without memset, we need to null the max link in a value node->values[SDS_BPTREE_DEFAULT_CAPACITY] = NULL; - node->level = 0xFFFFFFFF; + /* On cow, this value is over-written */ + node->level = 0xFFFF; node->item_count = 0; node->parent = NULL; node->txn_id = btxn->txn_id; @@ -228,7 +223,7 @@ sds_bptree_cow_node_create(sds_bptree_transaction *btxn) { // Update this becuase we are updating the created node lists. sds_bptree_crc32c_update_btxn(btxn); } - printf("sds_bptree_cow_node_create: Creating node_%p item_count=%d\n", node, node->item_count); + sds_log("sds_bptree_cow_node_create", "Creating node_%p item_count=%d\n", node, node->item_count); #endif return node; diff --git a/src/libsds/sds/bpt_cow/search.c b/src/libsds/sds/bpt_cow/search.c index 1dc312b..0b315fb 100644 --- a/src/libsds/sds/bpt_cow/search.c +++ b/src/libsds/sds/bpt_cow/search.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/txn.c b/src/libsds/sds/bpt_cow/txn.c index 676a41f..6dafa8b 100644 --- a/src/libsds/sds/bpt_cow/txn.c +++ b/src/libsds/sds/bpt_cow/txn.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/bpt_cow/verify.c b/src/libsds/sds/bpt_cow/verify.c index b6eba51..b12cb77 100644 --- a/src/libsds/sds/bpt_cow/verify.c +++ b/src/libsds/sds/bpt_cow/verify.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -77,7 +78,7 @@ sds_bptree_cow_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) { for (size_t i = 0; i < node->item_count; i++) { if (node->keys[i] == NULL) { - printf("%d \n", node->item_count); + sds_log("sds_bptree_cow_verify_node", "%d \n", node->item_count); return SDS_INVALID_KEY; } @@ -172,9 +173,6 @@ sds_bptree_cow_verify_node(sds_bptree_instance *binst, sds_bptree_node *node) { return SDS_INVALID_POINTER; } - if (lnode->level != node->level - 1 || rnode->level != node->level - 1) { - return SDS_INVALID_NODE; - } // Check that all left keys are LESS. sds_bptree_node_list *path = NULL; size_t j = 0; diff --git a/src/libsds/sds/core/crc32c.c b/src/libsds/sds/core/crc32c.c index cf5189f..a64a3f9 100644 --- a/src/libsds/sds/core/crc32c.c +++ b/src/libsds/sds/core/crc32c.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/core/utils.c b/src/libsds/sds/core/utils.c index 85ad9bc..80368d8 100644 --- a/src/libsds/sds/core/utils.c +++ b/src/libsds/sds/core/utils.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/queue/lqueue.c b/src/libsds/sds/queue/lqueue.c index 1b0253c..94c3548 100644 --- a/src/libsds/sds/queue/lqueue.c +++ b/src/libsds/sds/queue/lqueue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/queue/queue.c b/src/libsds/sds/queue/queue.c index 5cd280e..3aba012 100644 --- a/src/libsds/sds/queue/queue.c +++ b/src/libsds/sds/queue/queue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/queue/queue.h b/src/libsds/sds/queue/queue.h index 87d31ce..c86248a 100644 --- a/src/libsds/sds/queue/queue.h +++ b/src/libsds/sds/queue/queue.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/queue/tqueue.c b/src/libsds/sds/queue/tqueue.c index ee6ee55..0e75d22 100644 --- a/src/libsds/sds/queue/tqueue.c +++ b/src/libsds/sds/queue/tqueue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/sds/sds_internal.h b/src/libsds/sds/sds_internal.h index 8773d07..aee25d2 100644 --- a/src/libsds/sds/sds_internal.h +++ b/src/libsds/sds/sds_internal.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/benchmark.c b/src/libsds/test/benchmark.c index 621501f..1c351f6 100644 --- a/src/libsds/test/benchmark.c +++ b/src/libsds/test/benchmark.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -27,9 +28,9 @@ avl_intcmp(uint64_t *a, uint64_t *b) { } uint64_t * -avl_intdup(uint64_t a) { +avl_intdup(uint64_t *a) { uint64_t *b = malloc(sizeof(uint64_t)); - *b = a; + *b = *a; return b; } @@ -41,24 +42,15 @@ avl_init_wrapper(void **inst) { } int64_t -avl_add_wrapper(void **inst, void *key, void *value __attribute__((unused))) { +avl_add_wrapper(void **inst, uint64_t *key, void *value __attribute__((unused))) { Avlnode **tree = (Avlnode **)inst; - uint64_t ukey = (uint64_t)key; - if (ukey == 0) { - return 1; - } - return avl_insert(tree, avl_intdup(ukey), avl_intcmp, avl_dup_error); + return avl_insert(tree, avl_intdup(key), avl_intcmp, avl_dup_error); } int64_t -avl_search_wrapper(void **inst, void *key, void **value_out) { +avl_search_wrapper(void **inst, uint64_t *key, void **value_out) { Avlnode **tree = (Avlnode **)inst; - uint64_t *ukey = avl_intdup((uint64_t)key); - if (ukey == 0) { - return 1; - } - *value_out = avl_find(*tree, ukey, avl_intcmp); - free(ukey); + *value_out = avl_find(*tree, key, avl_intcmp); if (*value_out == NULL) { return 1; } @@ -66,16 +58,11 @@ avl_search_wrapper(void **inst, void *key, void **value_out) { } int64_t -avl_delete_wrapper(void **inst, void *key) { +avl_delete_wrapper(void **inst, uint64_t *key) { void *value_out = NULL; Avlnode **tree = (Avlnode **)inst; - uint64_t *ukey = avl_intdup((uint64_t)key); - if (ukey == 0) { - return 1; - } /* delete is broken :( */ - value_out = avl_find(*tree, ukey, avl_intcmp); - free(ukey); + value_out = avl_find(*tree, key, avl_intcmp); if (value_out == NULL) { return 1; } @@ -110,26 +97,26 @@ avl_destroy_wrapper(void **inst) { PLHashNumber hash_func_large(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_LARGE; } PLHashNumber hash_func_med(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_MED; } PLHashNumber hash_func_small(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_SMALL; } PRIntn hash_key_compare (const void *a, const void *b) { - uint64_t ia = (uint64_t)a; - uint64_t ib = (uint64_t)b; + uint64_t ia = *(uint64_t *)a; + uint64_t ib = *(uint64_t* )b; return ia == ib; } @@ -164,17 +151,18 @@ hash_large_init_wrapper(void **inst) { } int64_t -hash_add_wrapper(void **inst, void *key, void *value __attribute__((unused))) { +hash_add_wrapper(void **inst, uint64_t *key, void *value __attribute__((unused))) { PLHashTable **table = (PLHashTable **)inst; // WARNING: We have to add key as value too else hashmap won't add it!!! - PL_HashTableAdd(*table, key, key); + uint64_t *i = avl_intdup(key); + PL_HashTableAdd(*table, (void *)i, (void *)i); return 0; } int64_t -hash_search_wrapper(void **inst, void *key, void **value_out) { +hash_search_wrapper(void **inst, uint64_t *key, void **value_out) { PLHashTable **table = (PLHashTable **)inst; - *value_out = PL_HashTableLookup(*table, key); + *value_out = PL_HashTableLookup(*table, (void *)key); if (*value_out == NULL) { return 1; } @@ -182,9 +170,9 @@ hash_search_wrapper(void **inst, void *key, void **value_out) { } int64_t -hash_delete_wrapper(void **inst, void *key) { +hash_delete_wrapper(void **inst, uint64_t *key) { PLHashTable **table = (PLHashTable **)inst; - PL_HashTableRemove(*table, key); + PL_HashTableRemove(*table, (void *)key); return 0; } @@ -209,16 +197,16 @@ int64_t bptree_init_wrapper(void **inst) { return 0; } -int64_t bptree_add_wrapper(void **inst, void *key, void *value) { +int64_t bptree_add_wrapper(void **inst, uint64_t *key, void *value) { // THIS WILL BREAK SOMETIME! sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_bptree_insert(*binst, key, value); + sds_bptree_insert(*binst, (void *)key, value); return 0; } -int64_t bptree_search_wrapper(void **inst, void *key, void **value_out __attribute__((unused))) { +int64_t bptree_search_wrapper(void **inst, uint64_t *key, void **value_out __attribute__((unused))) { sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_result result = sds_bptree_search(*binst, key); + sds_result result = sds_bptree_search(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("search result is %d\n", result); return 1; @@ -226,9 +214,9 @@ int64_t bptree_search_wrapper(void **inst, void *key, void **value_out __attribu return 0; } -int64_t bptree_delete_wrapper(void **inst, void *key) { +int64_t bptree_delete_wrapper(void **inst, uint64_t *key) { sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_result result = sds_bptree_delete(*binst, key); + sds_result result = sds_bptree_delete(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("delete result is %d\n", result); @@ -252,16 +240,16 @@ int64_t bptree_cow_init_wrapper(void **inst) { return 0; } -int64_t bptree_cow_add_wrapper(void **inst, void *key, void *value) { +int64_t bptree_cow_add_wrapper(void **inst, uint64_t *key, void *value) { // THIS WILL BREAK SOMETIME! sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst; - sds_bptree_cow_insert_atomic(*binst, key, value); + sds_bptree_cow_insert_atomic(*binst, (void *)key, value); return 0; } -int64_t bptree_cow_search_wrapper(void **inst, void *key, void **value_out __attribute__((unused))) { +int64_t bptree_cow_search_wrapper(void **inst, uint64_t *key, void **value_out __attribute__((unused))) { sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst; - sds_result result = sds_bptree_cow_search_atomic(*binst, key); + sds_result result = sds_bptree_cow_search_atomic(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("search result is %d\n", result); return 1; @@ -269,9 +257,9 @@ int64_t bptree_cow_search_wrapper(void **inst, void *key, void **value_out __att return 0; } -int64_t bptree_cow_delete_wrapper(void **inst, void *key) { +int64_t bptree_cow_delete_wrapper(void **inst, uint64_t *key) { sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst; - sds_result result = sds_bptree_cow_delete_atomic(*binst, key); + sds_result result = sds_bptree_cow_delete_atomic(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("delete result is %d\n", result); return 1; @@ -301,7 +289,7 @@ bench_1_insert_seq(struct b_tree_cb *ds, uint64_t iter) { clock_gettime(CLOCK_MONOTONIC, &start_time); for (uint64_t i = 1; i < iter ; i++) { - if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) { + if (ds->add(&(ds->inst), &i, NULL) != 0) { printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name); break; } @@ -340,7 +328,7 @@ bench_2_search_seq(struct b_tree_cb *ds, uint64_t iter) { printf("BENCH: Start ...\n"); for (uint64_t i = 1; i < iter ; i++) { - if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) { + if (ds->add(&(ds->inst), &i, NULL) != 0) { printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name); break; } @@ -351,7 +339,7 @@ bench_2_search_seq(struct b_tree_cb *ds, uint64_t iter) { void *output; for (uint64_t j = 0; j < 100; j++) { for (uint64_t i = 1; i < iter ; i++) { - if (ds->search(&(ds->inst), (void *)(i + 1), &output) != 0) { + if (ds->search(&(ds->inst), &i, &output) != 0) { printf("FAIL: Error finding %" PRIu64 " in %s\n", i, ds->name); break; } @@ -390,7 +378,7 @@ bench_3_delete_seq(struct b_tree_cb *ds, uint64_t iter) { for (uint64_t i = 1; i < iter ; i++) { - if (ds->add(&(ds->inst), (void *)(i + 1), NULL) != 0) { + if (ds->add(&(ds->inst), &i, NULL) != 0) { printf("FAIL: Error inserting %" PRIu64 " to %s\n", i, ds->name); break; } @@ -400,7 +388,7 @@ bench_3_delete_seq(struct b_tree_cb *ds, uint64_t iter) { clock_gettime(CLOCK_MONOTONIC, &start_time); for (uint64_t i = 1; i < iter ; i++) { - if (ds->delete(&(ds->inst), (void *)(i + 1)) != 0) { + if (ds->delete(&(ds->inst), &i) != 0) { printf("FAIL: Error deleting %" PRIu64 " from %s\n", i, ds->name); break; } @@ -448,7 +436,8 @@ bench_4_insert_search_delete_random(struct b_tree_cb *ds, uint64_t iter) { for (size_t j = 0; j < max_factors; j++) { for (size_t i = 0; i < 2048 ; i++) { - ds->add(&(ds->inst), (void *)(fill_pattern[i] + (2048 << j)), NULL); + uint64_t x = fill_pattern[i] + (2048 << j); + ds->add(&(ds->inst), &x, NULL); } } @@ -458,12 +447,13 @@ bench_4_insert_search_delete_random(struct b_tree_cb *ds, uint64_t iter) { int mod = current_step % 10; cf = step % max_factors; + uint64_t x = fill_pattern[step % 2048] + (2048 << cf); if (mod >= 8) { - ds->delete(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf) )); + ds->delete(&(ds->inst), &x); } else if (mod >= 6) { - ds->add(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf)), NULL); + ds->add(&(ds->inst), &x, NULL); } else { - ds->search(&(ds->inst), (void *)(fill_pattern[step % 2048] + (2048 << cf)), &output); + ds->search(&(ds->inst), &x, &output); } } @@ -548,7 +538,7 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { uint64_t test_arrays[] = {5000, 10000, 100000, 500000, 1000000, 2500000, 5000000, 10000000}; - for (size_t i = 0; i < 2; i++) { + for (size_t i = 0; i < 3; i++) { bench_1_insert_seq(&avl_test, test_arrays[i]); bench_1_insert_seq(&hash_small_test, test_arrays[i]); bench_1_insert_seq(&hash_med_test, test_arrays[i]); diff --git a/src/libsds/test/benchmark.h b/src/libsds/test/benchmark.h index f40dbc7..b0c8a4d 100644 --- a/src/libsds/test/benchmark.h +++ b/src/libsds/test/benchmark.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -13,9 +14,9 @@ struct b_tree_cb { char *name; void *inst; int64_t (*init)(void **inst); - int64_t (*add)(void **inst, void *key, void *value); - int64_t (*search)(void **inst, void *key, void **value_out); - int64_t (*delete)(void **inst, void *key); + int64_t (*add)(void **inst, uint64_t *key, void *value); + int64_t (*search)(void **inst, uint64_t *key, void **value_out); + int64_t (*delete)(void **inst, uint64_t *key); int64_t (*destroy)(void **inst); }; diff --git a/src/libsds/test/benchmark_par.c b/src/libsds/test/benchmark_par.c index 8fa4ff7..2a43317 100644 --- a/src/libsds/test/benchmark_par.c +++ b/src/libsds/test/benchmark_par.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -111,25 +112,25 @@ batch_random(struct thread_info *info) { current_step = step + fill_pattern[step % 2048]; size_t mod = current_step % 10; cf = step % max_factors; - void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid); + uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid; if (mod >= 8) { info->ds->write_begin(&(info->ds->inst), &write_txn); - info->ds->delete(&(info->ds->inst), write_txn, target); + info->ds->delete(&(info->ds->inst), write_txn, &target); if (info->write_delay != 0) { usleep(info->write_delay); } info->ds->write_commit(&(info->ds->inst), write_txn); } else if (mod >= 6) { info->ds->write_begin(&(info->ds->inst), &write_txn); - info->ds->add(&(info->ds->inst), write_txn, target, NULL); + info->ds->add(&(info->ds->inst), write_txn, &target, NULL); if (info->write_delay != 0) { usleep(info->write_delay); } info->ds->write_commit(&(info->ds->inst), write_txn); } else { info->ds->read_begin(&(info->ds->inst), &read_txn); - info->ds->search(&(info->ds->inst), read_txn, target, &output); + info->ds->search(&(info->ds->inst), read_txn, &target, &output); if (info->read_delay != 0) { usleep(info->read_delay); } @@ -152,9 +153,9 @@ batch_search(struct thread_info *info) { info->ds->read_begin(&(info->ds->inst), &read_txn); for (size_t j = 0; j < info->batchsize; j++) { cf = (step * info->tid) % 2048; - void *target = (void *)(fill_pattern[cf] + j); + uint64_t target = fill_pattern[cf] + j; - info->ds->search(&(info->ds->inst), read_txn, target, &output); + info->ds->search(&(info->ds->inst), read_txn, &target, &output); } if (info->read_delay != 0) { usleep(info->read_delay); @@ -180,8 +181,8 @@ batch_insert(struct thread_info *info) { info->ds->write_begin(&(info->ds->inst), &write_txn); for (size_t j = 0; j < 10; j++) { cf = step % max_factors; - void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid); - info->ds->add(&(info->ds->inst), write_txn, target, NULL); + uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid; + info->ds->add(&(info->ds->inst), write_txn, &target, NULL); } if (info->write_delay != 0) { @@ -208,8 +209,8 @@ batch_delete(struct thread_info *info) { info->ds->write_begin(&(info->ds->inst), &write_txn); for (size_t j = 0; j < 10; j++) { cf = step % max_factors; - void *target = (void *)(fill_pattern[step % 2048] + (2048 << cf) + baseid); - info->ds->delete(&(info->ds->inst), write_txn, target); + uint64_t target = fill_pattern[step % 2048] + (2048 << cf) + baseid; + info->ds->delete(&(info->ds->inst), write_txn, &target); } if (info->write_delay != 0) { @@ -287,7 +288,8 @@ populate_ds(struct b_tree_cow_cb *ds, uint64_t iter) { ds->write_begin(&(ds->inst), &write_txn); for (size_t j = 0; j < max_factors; j++) { for (size_t i = 0; i < 2048 ; i++) { - ds->add(&(ds->inst), write_txn, (void *)(fill_pattern[i] + (2048 * j)), NULL); + uint64_t target = fill_pattern[i] + (2048 * j); + ds->add(&(ds->inst), write_txn, &target, NULL); count++; } } @@ -313,7 +315,7 @@ bench_insert_search_delete_batch(struct b_tree_cow_cb *ds, uint64_t iter) { info[i].op = batch_insert; info[i].batchsize = 10; } - for (; i < 2; i++) { + for (; i < 5; i++) { info[i].iter = iter; info[i].tid = i; info[i].ds = ds; @@ -567,11 +569,11 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { uint64_t test_arrays[] = {5000, 10000, 100000, 500000, 1000000, 2500000, 5000000, 10000000}; - for (size_t i = 0; i < 3; i++) { + for (size_t i = 0; i < 1; i++) { /* bench_insert_search_delete_batch(&hash_small_cb_test, test_arrays[i]); - */ bench_insert_search_delete_batch(&hash_med_cb_test, test_arrays[i]); + */ bench_insert_search_delete_batch(&hash_large_cb_test, test_arrays[i]); bench_insert_search_delete_batch(&bptree_test, test_arrays[i]); bench_insert_search_delete_batch(&bptree_cow_test, test_arrays[i]); @@ -579,8 +581,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_isd_write_delay(&hash_small_cb_test, test_arrays[i]); - */ bench_isd_write_delay(&hash_med_cb_test, test_arrays[i]); + */ bench_isd_write_delay(&hash_large_cb_test, test_arrays[i]); bench_isd_write_delay(&bptree_test, test_arrays[i]); bench_isd_write_delay(&bptree_cow_test, test_arrays[i]); @@ -588,8 +590,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_isd_read_delay(&hash_small_cb_test, test_arrays[i]); - */ bench_isd_read_delay(&hash_med_cb_test, test_arrays[i]); + */ bench_isd_read_delay(&hash_large_cb_test, test_arrays[i]); bench_isd_read_delay(&bptree_test, test_arrays[i]); bench_isd_read_delay(&bptree_cow_test, test_arrays[i]); @@ -597,8 +599,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_high_thread_small_batch_read(&hash_small_cb_test, test_arrays[i]); - */ bench_high_thread_small_batch_read(&hash_med_cb_test, test_arrays[i]); + */ bench_high_thread_small_batch_read(&hash_large_cb_test, test_arrays[i]); bench_high_thread_small_batch_read(&bptree_test, test_arrays[i]); bench_high_thread_small_batch_read(&bptree_cow_test, test_arrays[i]); @@ -606,8 +608,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_high_thread_large_batch_read(&hash_small_cb_test, test_arrays[i]); - */ bench_high_thread_large_batch_read(&hash_med_cb_test, test_arrays[i]); + */ bench_high_thread_large_batch_read(&hash_large_cb_test, test_arrays[i]); bench_high_thread_large_batch_read(&bptree_test, test_arrays[i]); bench_high_thread_large_batch_read(&bptree_cow_test, test_arrays[i]); @@ -615,8 +617,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_high_thread_small_batch_write(&hash_small_cb_test, test_arrays[i]); - */ bench_high_thread_small_batch_write(&hash_med_cb_test, test_arrays[i]); + */ bench_high_thread_small_batch_write(&hash_large_cb_test, test_arrays[i]); bench_high_thread_small_batch_write(&bptree_test, test_arrays[i]); bench_high_thread_small_batch_write(&bptree_cow_test, test_arrays[i]); @@ -624,8 +626,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_high_thread_large_batch_write(&hash_small_cb_test, test_arrays[i]); - */ bench_high_thread_large_batch_write(&hash_med_cb_test, test_arrays[i]); + */ bench_high_thread_large_batch_write(&hash_large_cb_test, test_arrays[i]); bench_high_thread_large_batch_write(&bptree_test, test_arrays[i]); bench_high_thread_large_batch_write(&bptree_cow_test, test_arrays[i]); @@ -633,8 +635,8 @@ main (int argc __attribute__((unused)), char **argv __attribute__((unused))) { /* bench_insert_search_delete_random(&hash_small_cb_test, test_arrays[i]); - */ bench_insert_search_delete_random(&hash_med_cb_test, test_arrays[i]); + */ bench_insert_search_delete_random(&hash_large_cb_test, test_arrays[i]); bench_insert_search_delete_random(&bptree_test, test_arrays[i]); bench_insert_search_delete_random(&bptree_cow_test, test_arrays[i]); diff --git a/src/libsds/test/benchmark_par.h b/src/libsds/test/benchmark_par.h index 418cfb3..2507c3b 100644 --- a/src/libsds/test/benchmark_par.h +++ b/src/libsds/test/benchmark_par.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -17,9 +18,9 @@ struct b_tree_cow_cb { int64_t (*read_complete)(void **inst, void *read_txn); int64_t (*write_begin)(void **inst, void **write_txn); int64_t (*write_commit)(void **inst, void *write_txn); - int64_t (*add)(void **inst, void *write_txn, void *key, void *value); - int64_t (*search)(void **inst, void *read_txn, void *key, void **value_out); - int64_t (*delete)(void **inst, void *write_txn, void *key); + int64_t (*add)(void **inst, void *write_txn, uint64_t *key, void *value); + int64_t (*search)(void **inst, void *read_txn, uint64_t *key, void **value_out); + int64_t (*delete)(void **inst, void *write_txn, uint64_t *key); int64_t (*destroy)(void **inst); }; @@ -48,9 +49,9 @@ int64_t bptree_read_begin(void **inst, void **txn); int64_t bptree_read_complete(void **inst, void *txn); int64_t bptree_write_begin(void **inst, void **txn); int64_t bptree_write_commit(void **inst, void *txn); -int64_t bptree_add_wrapper(void **inst, void *txn, void *key, void *value); -int64_t bptree_search_wrapper(void **inst, void *txn, void *key, void **value_out); -int64_t bptree_delete_wrapper(void **inst, void *txn, void *key); +int64_t bptree_add_wrapper(void **inst, void *txn, uint64_t *key, void *value); +int64_t bptree_search_wrapper(void **inst, void *txn, uint64_t *key, void **value_out); +int64_t bptree_delete_wrapper(void **inst, void *txn, uint64_t *key); int64_t bptree_destroy_wrapper(void **inst); int64_t bptree_cow_init_wrapper(void **inst); @@ -58,16 +59,16 @@ int64_t bptree_cow_read_begin(void **inst, void **read_txn); int64_t bptree_cow_read_complete(void **inst, void *read_txn); int64_t bptree_cow_write_begin(void **inst, void **write_txn); int64_t bptree_cow_write_commit(void **inst, void *write_txn); -int64_t bptree_cow_add_wrapper(void **inst, void *write_txn, void *key, void *value); -int64_t bptree_cow_search_wrapper(void **inst, void *read_txn, void *key, void **value_out); -int64_t bptree_cow_delete_wrapper(void **inst, void *write_txn, void *key); +int64_t bptree_cow_add_wrapper(void **inst, void *write_txn, uint64_t *key, void *value); +int64_t bptree_cow_search_wrapper(void **inst, void *read_txn, uint64_t *key, void **value_out); +int64_t bptree_cow_delete_wrapper(void **inst, void *write_txn, uint64_t *key); int64_t bptree_cow_destroy_wrapper(void **inst); /* Hash map structures */ int64_t hash_small_init_wrapper(void **inst); int64_t hash_med_init_wrapper(void **inst); int64_t hash_large_init_wrapper(void **inst); -int64_t hash_add_wrapper(void **inst, void *write_txn, void *key, void *value); -int64_t hash_search_wrapper(void **inst, void *read_txn, void *key, void **value_out); -int64_t hash_delete_wrapper(void **inst, void *write_txn, void *key); +int64_t hash_add_wrapper(void **inst, void *write_txn, uint64_t *key, void *value); +int64_t hash_search_wrapper(void **inst, void *read_txn, uint64_t *key, void **value_out); +int64_t hash_delete_wrapper(void **inst, void *write_txn, uint64_t *key); int64_t hash_destroy_wrapper(void **inst); diff --git a/src/libsds/test/benchmark_parwrap.c b/src/libsds/test/benchmark_parwrap.c index 36fe9db..747bc1c 100644 --- a/src/libsds/test/benchmark_parwrap.c +++ b/src/libsds/test/benchmark_parwrap.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -69,16 +70,16 @@ int64_t bptree_init_wrapper(void **inst) { return 0; } -int64_t bptree_add_wrapper(void **inst, void *txn __attribute__((unused)), void *key, void *value) { +int64_t bptree_add_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key, void *value) { // THIS WILL BREAK SOMETIME! sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_bptree_insert(*binst, key, value); + sds_bptree_insert(*binst, (void*)key, value); return 0; } -int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), void *key, void **value_out __attribute__((unused))) { +int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key, void **value_out __attribute__((unused))) { sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_result result = sds_bptree_search(*binst, key); + sds_result result = sds_bptree_search(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("search result is %d\n", result); return 1; @@ -86,9 +87,9 @@ int64_t bptree_search_wrapper(void **inst, void *txn __attribute__((unused)), vo return 0; } -int64_t bptree_delete_wrapper(void **inst, void *txn __attribute__((unused)), void *key) { +int64_t bptree_delete_wrapper(void **inst, void *txn __attribute__((unused)), uint64_t *key) { sds_bptree_instance **binst = (sds_bptree_instance **)inst; - sds_result result = sds_bptree_delete(*binst, key); + sds_result result = sds_bptree_delete(*binst, (void *)key); if (result != SDS_KEY_PRESENT) { // printf("delete result is %d\n", result); @@ -148,26 +149,26 @@ int64_t bptree_cow_write_commit(void **inst __attribute__((unused)), void *write return 0; } -int64_t bptree_cow_add_wrapper(void **inst __attribute__((unused)), void *write_txn, void *key, void *value) { +int64_t bptree_cow_add_wrapper(void **inst __attribute__((unused)), void *write_txn, uint64_t *key, void *value) { // THIS WILL BREAK SOMETIME! sds_bptree_transaction *txn = (sds_bptree_transaction *)write_txn; - sds_bptree_cow_insert(txn, key, value); + sds_bptree_cow_insert(txn, (void *)key, value); return 0; } -int64_t bptree_cow_search_wrapper(void **inst __attribute__((unused)), void *read_txn, void *key, void **value_out __attribute__((unused))) { +int64_t bptree_cow_search_wrapper(void **inst __attribute__((unused)), void *read_txn, uint64_t *key, void **value_out __attribute__((unused))) { sds_bptree_transaction *txn = (sds_bptree_transaction *)read_txn; - sds_result result = sds_bptree_cow_search(txn, key); + sds_result result = sds_bptree_cow_search(txn, (void *)key); if (result != SDS_KEY_PRESENT) { return 1; } return 0; } -int64_t bptree_cow_delete_wrapper(void **inst __attribute__((unused)), void *write_txn, void *key) { +int64_t bptree_cow_delete_wrapper(void **inst __attribute__((unused)), void *write_txn, uint64_t *key) { // sds_bptree_cow_instance **binst = (sds_bptree_cow_instance **)inst; sds_bptree_transaction *txn = (sds_bptree_transaction *)write_txn; - sds_result result = sds_bptree_cow_delete(txn, key); + sds_result result = sds_bptree_cow_delete(txn, (void *)key); if (result != SDS_KEY_PRESENT) { return 1; } @@ -204,26 +205,26 @@ int64_t bptree_cow_destroy_wrapper(void **inst) { PLHashNumber hash_func_large(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_LARGE; } PLHashNumber hash_func_med(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_MED; } PLHashNumber hash_func_small(const void *key) { - uint64_t ik = (uint64_t)key; + uint64_t ik = *(uint64_t *)key; return ik % HASH_BUCKETS_SMALL; } PRIntn hash_key_compare (const void *a, const void *b) { - uint64_t ia = (uint64_t)a; - uint64_t ib = (uint64_t)b; + uint64_t ia = *(uint64_t *)a; + uint64_t ib = *(uint64_t *)b; return ia == ib; } @@ -273,15 +274,16 @@ hash_large_init_wrapper(void **inst) { } int64_t -hash_add_wrapper(void **inst, void *write_txn __attribute__((unused)), void *key, void *value __attribute__((unused))) { +hash_add_wrapper(void **inst, void *write_txn __attribute__((unused)), uint64_t *key, void *value __attribute__((unused))) { PLHashTable **table = (PLHashTable **)inst; // WARNING: We have to add key as value too else hashmap won't add it!!! - PL_HashTableAdd(*table, key, key); + uint64_t *i = sds_uint64_t_dup(key); + PL_HashTableAdd(*table, i, i); return 0; } int64_t -hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), void *key, void **value_out) { +hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), uint64_t *key, void **value_out) { PLHashTable **table = (PLHashTable **)inst; *value_out = PL_HashTableLookup(*table, key); if (*value_out == NULL) { @@ -291,7 +293,7 @@ hash_search_wrapper(void **inst, void *read_txn __attribute__((unused)), void *k } int64_t -hash_delete_wrapper(void **inst, void *write_txn __attribute__((unused)), void *key) { +hash_delete_wrapper(void **inst, void *write_txn __attribute__((unused)), uint64_t *key) { PLHashTable **table = (PLHashTable **)inst; PL_HashTableRemove(*table, key); return 0; diff --git a/src/libsds/test/test_fixtures.c b/src/libsds/test/test_fixtures.c index a530c02..49bce57 100644 --- a/src/libsds/test/test_fixtures.c +++ b/src/libsds/test/test_fixtures.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds.c b/src/libsds/test/test_sds.c index 276d3d5..dff5b8b 100644 --- a/src/libsds/test/test_sds.c +++ b/src/libsds/test/test_sds.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds.h b/src/libsds/test/test_sds.h index 994611a..4755d5e 100644 --- a/src/libsds/test/test_sds.h +++ b/src/libsds/test/test_sds.h @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds_bpt.c b/src/libsds/test/test_sds_bpt.c index 3243026..13f8177 100644 --- a/src/libsds/test/test_sds_bpt.c +++ b/src/libsds/test/test_sds_bpt.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -189,8 +190,10 @@ test_11_tamper_with_node(void **state __attribute__((unused))) { binst->root->keys[0] = (void *)1; +#ifdef DEBUG result = sds_bptree_verify(binst); assert_int_equal(result, SDS_CHECKSUM_FAILURE); +#endif result = sds_bptree_destroy(binst); assert_int_equal(result, SDS_SUCCESS); @@ -444,17 +447,10 @@ test_21_delete_redist_left_leaf(void **state) // I is increment 1 extra, so decrement it .... i--; - -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n", i); -#endif result = sds_bptree_delete(binst, (void *)&i); assert_int_equal(result, SDS_KEY_PRESENT); i--; -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n", i); -#endif result = sds_bptree_delete(binst, (void *)&i); assert_int_equal(result, SDS_KEY_PRESENT); @@ -539,9 +535,6 @@ test_22_5_redist_left_borrow(void **state) assert_int_equal(result, SDS_SUCCESS); for (uint64_t i = SDS_BPTREE_DEFAULT_CAPACITY; i > 2 ; i--) { -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n ", i); -#endif key = i + 1; result = sds_bptree_delete(binst, (void *)&key); assert_int_equal(result, SDS_KEY_PRESENT); @@ -625,9 +618,6 @@ test_24_delete_left_merge(void **state) for (i = SDS_BPTREE_DEFAULT_CAPACITY; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 2) ; i++) { // Add two to guarantee we don't conflict -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n ", i); -#endif result = sds_bptree_delete(binst, (void *)&i); assert_int_equal(result, SDS_KEY_PRESENT); } @@ -651,9 +641,6 @@ test_25_delete_all_compress_root(void **state) for (i = 1; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 3); i++) { // Add two to guarantee we don't conflict -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n ", i); -#endif result = sds_bptree_delete(binst, (void *)&i); assert_int_equal(result, SDS_KEY_PRESENT); } @@ -741,9 +728,6 @@ test_27_delete_left_branch_merge(void **state) // And A should be removed too. for (i = SDS_BPTREE_DEFAULT_CAPACITY * 2; i <= (SDS_BPTREE_DEFAULT_CAPACITY * 6) ; i++) { // Add two to guarantee we don't conflict -#ifdef DEBUG - printf("Deleting %" PRIu64 "\n ", i); -#endif result = sds_bptree_delete(binst, (void *)&i); assert_int_equal(result, SDS_KEY_PRESENT); result = sds_bptree_verify(binst); diff --git a/src/libsds/test/test_sds_cow.c b/src/libsds/test/test_sds_cow.c index 4ad5375..d4fcfda 100644 --- a/src/libsds/test/test_sds_cow.c +++ b/src/libsds/test/test_sds_cow.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds_lqueue.c b/src/libsds/test/test_sds_lqueue.c index db91a8d..fb515ea 100644 --- a/src/libsds/test/test_sds_lqueue.c +++ b/src/libsds/test/test_sds_lqueue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds_queue.c b/src/libsds/test/test_sds_queue.c index 45d14d9..03da7a1 100644 --- a/src/libsds/test/test_sds_queue.c +++ b/src/libsds/test/test_sds_queue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ diff --git a/src/libsds/test/test_sds_set.c b/src/libsds/test/test_sds_set.c index 3b27873..159b69c 100644 --- a/src/libsds/test/test_sds_set.c +++ b/src/libsds/test/test_sds_set.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/ @@ -16,9 +17,6 @@ static int32_t cb_count = 0; static void test_31_map_cb(void *k, void *v) { -#ifdef DEBUG - printf("mapping %" PRIu64 ":%s\n", (uint64_t)k, (char *)v); -#endif cb_count++; } @@ -273,9 +271,6 @@ test_38_set_compliment_2(void **state) { static int64_t test_39_filter_cb(void *k, void *v) { -#ifdef DEBUG - printf("filtering %" PRIu64 ":%s\n", *(uint64_t *)k, (char *)v); -#endif if (*(uint64_t *)k % 2 == 0) { return 1; } diff --git a/src/libsds/test/test_sds_tqueue.c b/src/libsds/test/test_sds_tqueue.c index c150c57..f5596bd 100644 --- a/src/libsds/test/test_sds_tqueue.c +++ b/src/libsds/test/test_sds_tqueue.c @@ -1,8 +1,9 @@ /** BEGIN COPYRIGHT BLOCK * Copyright (c) 2016, William Brown + * Copyright (c) 2017, Red Hat, Inc * All rights reserved. * - * License: License: GPL (version 3 or any later version). + * License: GPL (version 3 or any later version). * See LICENSE for details. * END COPYRIGHT BLOCK **/