dbug stuff. for now, you have to edit cmakelists.txt to set the location of dbug.
This commit is contained in:
parent
34fec57c07
commit
14d8cebdcc
5 changed files with 80 additions and 22 deletions
|
@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 2.4) # For all I know, 2.0 works too...
|
|||
# The new behavior seems preferable, though it shouldn't affect us either way.
|
||||
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0014 OLD)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
|
@ -65,6 +66,14 @@ INCLUDE(CheckCSourceCompiles)
|
|||
CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE)
|
||||
CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC)
|
||||
CHECK_FUNCTION_EXISTS(tdestroy HAVE_TDESTROY)
|
||||
|
||||
FIND_LIBRARY(DBUG_TEST dbug-stubs /home/sears/local/dbug/lib/)
|
||||
if(NOT DBUG_TEST)
|
||||
message(STATUS "dbug not found. proceeding with normal build")
|
||||
else(NOT DBUG_TEST)
|
||||
message(STATUS "found dbug ${DBUG_TEST}")
|
||||
endif(NOT DBUG_TEST)
|
||||
|
||||
SET(CMAKE_REQUIRED_FLAGS "-lm")
|
||||
CHECK_FUNCTION_EXISTS(powl HAVE_POWL)
|
||||
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE
|
||||
|
@ -124,7 +133,7 @@ ENDMACRO(CREATE_EXECUTABLE)
|
|||
|
||||
# Output the config.h file
|
||||
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/build
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
/usr/include)
|
||||
|
@ -132,7 +141,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/build
|
|||
LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src/stasis)
|
||||
|
||||
IF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
|
||||
SET(COMMON_LIBRARIES stasis m pthread stdc++)
|
||||
SET(COMMON_LIBRARIES stasis m pthread stdc++ ${DBUG_TEST})
|
||||
SET(CMAKE_C_FLAGS "-g -Wall -pedantic -std=gnu99 -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-long-long -pedantic -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}")
|
||||
ELSEIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro" )
|
||||
|
@ -142,7 +151,7 @@ ELSEIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro" )
|
|||
ELSE( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
|
||||
# TODO: how to detect compilers correctly on old cmake??? This is a huge hack; it uses old gcc
|
||||
# options, since cmake is old...
|
||||
SET(COMMON_LIBRARIES stasis m pthread stdc++)
|
||||
SET(COMMON_LIBRARIES stasis m pthread stdc++ ${DBUG_TEST})
|
||||
SET(CMAKE_C_FLAGS "-g -Wall -pedantic -std=gnu99 -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-long-long -pedantic -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}")
|
||||
ENDIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#cmakedefine HAVE_ALLOCA_H
|
||||
#cmakedefine HAVE_TDESTROY
|
||||
#cmakedefine HAVE_POWL
|
||||
|
||||
#cmakedefine DBUG_TEST
|
||||
#ifndef HAVE_PTHREAD_STACK_MIN
|
||||
#define PTHREAD_STACK_MIN 32768 // wild guess.
|
||||
#endif
|
||||
|
|
|
@ -54,8 +54,11 @@ static inline pageid_t hash6432shift(pageid_t key)
|
|||
// return (key | 64) ^ ((key >> 15) | (key << 17));
|
||||
|
||||
// return stasis_crc32(&key, sizeof(key), 0);
|
||||
#ifdef DBUG_TEST
|
||||
return key;
|
||||
#else
|
||||
return key * 13;
|
||||
|
||||
#endif
|
||||
}
|
||||
static inline pageid_t hashtable_func(hashtable_t *ht, pageid_t key) {
|
||||
return hashtable_wrap(ht, hash6432shift(key));
|
||||
|
|
|
@ -58,14 +58,25 @@ terms specified in this license.
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
extern int dbug_choice(int);
|
||||
#endif
|
||||
|
||||
#define LOG_NAME "check_lhtable.log"
|
||||
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
#define NUM_OPS 4
|
||||
#define NUM_ENTRIES 4
|
||||
#define NUM_THREADS 2
|
||||
#define THREAD_ENTRIES 2
|
||||
#define HT_ENTRIES 16
|
||||
#define myrandom(x) dbug_choice(x)
|
||||
#else
|
||||
#define NUM_OPS 10000000
|
||||
#define NUM_ENTRIES 10000
|
||||
#define NUM_THREADS 100
|
||||
#define THREAD_ENTRIES ((NUM_ENTRIES/NUM_THREADS)-1)
|
||||
|
||||
#endif
|
||||
hashtable_t * ht;
|
||||
|
||||
void * worker(void * arg) {
|
||||
|
@ -73,10 +84,17 @@ void * worker(void * arg) {
|
|||
|
||||
pageid_t *data = malloc(sizeof(pageid_t) * THREAD_ENTRIES);
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
for(int i = 1; i <= THREAD_ENTRIES; i++) {
|
||||
data[i-1] = -1 * (stride + (i * HT_ENTRIES));
|
||||
}
|
||||
#else
|
||||
for(int i = 1; i <= THREAD_ENTRIES; i++) {
|
||||
data[i-1] = -1 * (stride + (i * NUM_THREADS));
|
||||
}
|
||||
for(int j = 0; j < NUM_OPS/ NUM_THREADS; j++) {
|
||||
#endif
|
||||
for(int j = 0; j < NUM_OPS/*/ NUM_THREADS*/; j++) {
|
||||
|
||||
int op = myrandom(2);
|
||||
|
||||
int i = myrandom(THREAD_ENTRIES);
|
||||
|
@ -115,14 +133,22 @@ void * worker(void * arg) {
|
|||
}
|
||||
|
||||
START_TEST(singleThreadHashTest) {
|
||||
#ifdef DBUG_TEST
|
||||
ht = hashtable_init((pageid_t)HT_ENTRIES);
|
||||
#else
|
||||
ht = hashtable_init((pageid_t)((double)THREAD_ENTRIES * 1.1));
|
||||
#endif
|
||||
int i = 0;
|
||||
worker(&i);
|
||||
hashtable_deinit(ht);
|
||||
} END_TEST
|
||||
|
||||
START_TEST(concurrentHashTest) {
|
||||
#ifdef DBUG_TEST
|
||||
ht = hashtable_init((pageid_t)HT_ENTRIES);
|
||||
#else
|
||||
ht = hashtable_init((pageid_t)((double)NUM_ENTRIES * 1.1));
|
||||
#endif
|
||||
pthread_t workers[NUM_THREADS];
|
||||
for(int i = 0 ; i < NUM_THREADS; i++) {
|
||||
int * ip = malloc(sizeof(int));
|
||||
|
@ -146,8 +172,9 @@ Suite * check_suite(void) {
|
|||
|
||||
/* Sub tests are added, one per line, here */
|
||||
tcase_add_test(tc, singleThreadHashTest);
|
||||
#ifndef DBUG_TEST // TODO should run exactly one of these two tests under dbug. Need good way to choose which one.
|
||||
tcase_add_test(tc, concurrentHashTest);
|
||||
|
||||
#endif
|
||||
/* --------------------------------------------- */
|
||||
|
||||
tcase_add_checked_fixture(tc, setup, teardown);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#undef STLSEARCH
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
extern int dbug_choice(int);
|
||||
#endif
|
||||
|
||||
#include <stasis/redblack.h>
|
||||
#include <stasis/stlredblack.h>
|
||||
|
||||
|
@ -63,37 +67,52 @@ static void assert_equal(const void * rb_ret_1, const void * rb_ret_2,
|
|||
/* Create two libredblack trees and two stl trees. Use different orders with consistent == for each pair */
|
||||
START_TEST(rbRandTest) {
|
||||
|
||||
time_t seed = time(0);
|
||||
printf("\nSeed = %ld\n", seed);
|
||||
srandom(seed);
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
uint64_t NUM_OPERATIONS = 6;
|
||||
uint64_t NUM_ENTRIES = 3;
|
||||
uint64_t NUM_A = 3;
|
||||
uint64_t NUM_B = 1;
|
||||
# define myrandom(a) dbug_choice(a)
|
||||
#else
|
||||
uint64_t NUM_OPERATIONS = 1000 * 1000;
|
||||
uint64_t NUM_ENTRIES = myrandom(100 * 1000);
|
||||
uint64_t NUM_A = myrandom(200);
|
||||
uint64_t NUM_B = myrandom(50000);
|
||||
#endif
|
||||
printf("NUM_OPERATIONS = %lld NUM_ENTRIES = %lld NUM_A = %lld NUM_B = %lld\n",
|
||||
(long long int)NUM_OPERATIONS, (long long int)NUM_ENTRIES, (long long int)NUM_A, (long long int)NUM_B);
|
||||
|
||||
rbtree *rb_1 = rbinit(cmp_1, NULL);
|
||||
rbtree *rb_2 = rbinit(cmp_2, NULL);
|
||||
rbtree *stl_1 = stl_rbinit(cmp_1, NULL);
|
||||
rbtree *stl_2 = stl_rbinit(cmp_2, NULL);
|
||||
|
||||
time_t seed = time(0);
|
||||
printf("\nSeed = %ld\n", seed);
|
||||
srandom(seed);
|
||||
|
||||
|
||||
uint64_t NUM_ENTRIES = myrandom(100 * 1000);
|
||||
uint64_t NUM_A = myrandom(200);
|
||||
uint64_t NUM_B = myrandom(50000);
|
||||
|
||||
printf("NUM_OPERATIONS = %lld NUM_ENTRIES = %lld NUM_A = %lld NUM_B = %lld\n",
|
||||
(long long int)NUM_OPERATIONS, (long long int)NUM_ENTRIES, (long long int)NUM_A, (long long int)NUM_B);
|
||||
|
||||
tup * entries = malloc(sizeof(tup) * NUM_ENTRIES);
|
||||
|
||||
#ifdef DBUG_TEST
|
||||
for(uint64_t i = 0; i < NUM_ENTRIES; i++) {
|
||||
entries[i].a = i;
|
||||
entries[i].b = 0;
|
||||
}
|
||||
#else
|
||||
for(uint64_t i = 0; i < NUM_ENTRIES; i++) {
|
||||
entries[i].a = myrandom(NUM_A);
|
||||
entries[i].b = myrandom(NUM_B);
|
||||
}
|
||||
#endif
|
||||
uint64_t num_found = 0;
|
||||
uint64_t num_collide = 0;
|
||||
for(uint64_t i = 0; i < NUM_OPERATIONS; i++) {
|
||||
uint64_t off = myrandom(NUM_ENTRIES);
|
||||
#ifdef DBUG_TEST
|
||||
switch(myrandom(3)+1) {
|
||||
#else
|
||||
switch(myrandom(4)) {
|
||||
case 0:
|
||||
#endif
|
||||
case 1: { // insert
|
||||
const void * rb_ret_1 = rbsearch(&entries[off], rb_1);
|
||||
const void * rb_ret_2 = rbsearch(&entries[off], rb_2);
|
||||
|
|
Loading…
Reference in a new issue