CUBRID Engine
latest
|
#include "porting.h"
#include "lock_free.h"
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
Go to the source code of this file.
Classes | |
struct | xentry |
Macros | |
#define | strlen(s1) ((int) strlen(s1)) |
#define | RAND_BLOCKS 64 |
#define | RAND_BLOCK_SIZE 1000000 |
#define | RAND_SIZE RAND_BLOCKS * RAND_BLOCK_SIZE |
#define | PTHREAD_ABORT_AND_EXIT(code) |
#define | MSG_LEN 40 |
#define | NOPS 1000000 /* 1M */ |
#define | NOPS 1000000 /* 1M */ |
#define | NOPS 1000000 |
#define | NOPS 1000000 |
#define | NOPS 1000000 |
#define | NOPS 1000000 |
#define | NOPS 1000000 |
#define | NOPS 1000000 |
#define | MAX_THREADS 64 |
#define | MAX_THREADS 1024 |
#define | HASH_SIZE 113 |
#define | HASH_SIZE 200 |
#define | HASH_POPULATION HASH_SIZE * 5 |
#define | NUM_THREADS 16 |
Typedefs | |
typedef struct xentry | XENTRY |
using | my_hashmap = lf_hash_table_cpp< int, xentry > |
using | my_hashmap_iterator = my_hashmap::iterator |
Functions | |
static void | generate_random () |
static void * | xentry_alloc () |
static int | xentry_free (void *entry) |
static int | xentry_init (void *entry) |
static int | xentry_uninit (void *entry) |
static unsigned int | xentry_hash (void *key, int htsize) |
static int | xentry_key_compare (void *k1, void *k2) |
static int | xentry_key_copy (void *src, void *dest) |
static void | begin (const char *test_name) |
static int | fail (const char *message) |
static int | success () |
void * | test_freelist_proc (void *param) |
void * | test_freelist_proc_local_tran (void *param) |
void * | test_hash_proc_1 (void *param) |
void * | test_hash_proc_2 (void *param) |
void * | test_hash_proc_3 (void *param) |
void * | test_clear_proc_1 (void *param) |
void * | test_clear_proc_2 (void *param) |
void * | test_clear_proc_3 (void *param) |
static int | test_freelist (LF_ENTRY_DESCRIPTOR *edesc, int nthreads, bool test_local_tran) |
static int | test_hash_table (LF_ENTRY_DESCRIPTOR *edesc, int nthreads, void *(*proc)(void *)) |
static int | test_hash_iterator () |
int | main (int argc, char **argv) |
Variables | |
static int | random_numbers [RAND_SIZE] |
static LF_ENTRY_DESCRIPTOR | xentry_desc |
static struct timeval | start_time |
static int | del_op_count = -1 |
#define HASH_POPULATION HASH_SIZE * 5 |
Referenced by test_hash_iterator().
#define HASH_SIZE 113 |
Referenced by test_hash_iterator(), and test_hash_table().
#define HASH_SIZE 200 |
#define MAX_THREADS 64 |
Referenced by test_freelist(), and test_hash_table().
#define MAX_THREADS 1024 |
#define MSG_LEN 40 |
Referenced by begin().
#define NOPS 1000000 /* 1M */ |
#define NOPS 1000000 /* 1M */ |
#define NOPS 1000000 |
#define NOPS 1000000 |
#define NOPS 1000000 |
#define NOPS 1000000 |
#define NOPS 1000000 |
#define NOPS 1000000 |
#define NUM_THREADS 16 |
Referenced by test_hash_iterator().
#define PTHREAD_ABORT_AND_EXIT | ( | code | ) |
Definition at line 39 of file unittests_lf.c.
Referenced by test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_freelist_proc(), test_freelist_proc_local_tran(), test_hash_proc_1(), test_hash_proc_2(), and test_hash_proc_3().
#define RAND_BLOCK_SIZE 1000000 |
Definition at line 35 of file unittests_lf.c.
Referenced by test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_hash_proc_1(), test_hash_proc_2(), and test_hash_proc_3().
#define RAND_BLOCKS 64 |
Definition at line 34 of file unittests_lf.c.
Referenced by test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_hash_proc_1(), test_hash_proc_2(), and test_hash_proc_3().
#define RAND_SIZE RAND_BLOCKS * RAND_BLOCK_SIZE |
Definition at line 36 of file unittests_lf.c.
Referenced by generate_random().
#define strlen | ( | s1 | ) | ((int) strlen(s1)) |
Definition at line 31 of file unittests_lf.c.
Referenced by begin().
using my_hashmap = lf_hash_table_cpp<int, xentry> |
Definition at line 76 of file unittests_lf.c.
Definition at line 77 of file unittests_lf.c.
Definition at line 62 of file unittests_lf.c.
|
static |
Definition at line 181 of file unittests_lf.c.
References i, MSG_LEN, NULL, start_time, and strlen.
Referenced by test_freelist(), test_hash_iterator(), and test_hash_table().
|
static |
Definition at line 199 of file unittests_lf.c.
References ER_FAILED.
Referenced by main(), test_freelist(), test_hash_iterator(), and test_hash_table().
|
static |
Definition at line 49 of file unittests_lf.c.
References i, NULL, RAND_SIZE, and random_numbers.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 1052 of file unittests_lf.c.
References del_op_count, ER_FAILED, fail(), generate_random(), i, LF_EM_USING_MUTEX, NO_ERROR, test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_freelist(), test_hash_iterator(), test_hash_proc_1(), test_hash_proc_2(), test_hash_proc_3(), test_hash_table(), and lf_entry_descriptor::using_mutex.
|
static |
Definition at line 207 of file unittests_lf.c.
References NO_ERROR, NULL, start_time, and test_freelist_proc().
Referenced by test_clear_proc_3(), test_freelist(), test_hash_iterator(), test_hash_proc_3(), and test_hash_table().
void * test_clear_proc_1 | ( | void * | param | ) |
Definition at line 512 of file unittests_lf.c.
References lf_hash_table_cpp< Key, T >::clear(), lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, test_clear_proc_2(), lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main(), and test_hash_proc_3().
void * test_clear_proc_2 | ( | void * | param | ) |
Definition at line 572 of file unittests_lf.c.
References assert, lf_hash_table_cpp< Key, T >::clear(), lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), xentry::mutex, NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, test_clear_proc_3(), lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main(), and test_clear_proc_1().
void * test_clear_proc_3 | ( | void * | param | ) |
Definition at line 641 of file unittests_lf.c.
References assert, lf_hash_table_cpp< Key, T >::clear(), xentry::data, lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase_locked(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), xentry::mutex, NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, success(), lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main(), and test_clear_proc_2().
|
static |
Definition at line 721 of file unittests_lf.c.
References lf_freelist::alloc_cnt, lf_freelist::available, lf_freelist::available_cnt, begin(), lf_tran_system::entries, lf_tran_system::entry_count, fail(), i, lf_freelist_destroy(), lf_freelist_init(), lf_tran_system_destroy(), lf_tran_system_init(), MAX_THREADS, NO_ERROR, NULL, lf_freelist::retired_cnt, lf_tran_entry::retired_list, xentry::stack, success(), test_freelist_proc(), test_freelist_proc_local_tran(), and VOLATILE_ACCESS.
Referenced by main().
void * test_freelist_proc | ( | void * | param | ) |
Definition at line 225 of file unittests_lf.c.
References ER_FAILED, i, lf_freelist_claim(), lf_freelist_retire(), lf_tran_end_with_mb, lf_tran_request_entry(), lf_tran_return_entry(), lf_tran_start_with_mb, NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, test_freelist_proc_local_tran(), and lf_freelist::tran_system.
Referenced by success(), and test_freelist().
void * test_freelist_proc_local_tran | ( | void * | param | ) |
Definition at line 274 of file unittests_lf.c.
References ER_FAILED, i, lf_freelist_claim(), lf_freelist_retire(), lf_tran_request_entry(), lf_tran_return_entry(), NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, test_hash_proc_1(), and lf_freelist::tran_system.
Referenced by test_freelist(), and test_freelist_proc().
|
static |
Definition at line 967 of file unittests_lf.c.
References begin(), lf_hash_table_cpp< Key, T >::clear(), xentry::data, lf_hash_table_cpp< Key, T >::destroy(), fail(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table_cpp< Key, T >::get_freelist(), lf_hash_table_cpp< Key, T >::get_hash_table(), HASH_POPULATION, HASH_SIZE, i, lf_hash_table_cpp< Key, T >::init(), lf_tran_request_entry(), lf_tran_return_entry(), lf_tran_system_destroy(), lf_tran_system_init(), NO_ERROR, NULL, NUM_THREADS, success(), and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main().
void * test_hash_proc_1 | ( | void * | param | ) |
Definition at line 320 of file unittests_lf.c.
References lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, test_hash_proc_2(), lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main(), and test_freelist_proc_local_tran().
void * test_hash_proc_2 | ( | void * | param | ) |
Definition at line 372 of file unittests_lf.c.
References assert, lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), xentry::mutex, NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main(), and test_hash_proc_1().
void * test_hash_proc_3 | ( | void * | param | ) |
Definition at line 437 of file unittests_lf.c.
References assert, xentry::data, del_op_count, lf_tran_entry::entry_idx, ER_FAILED, lf_hash_table_cpp< Key, T >::erase_locked(), lf_hash_table_cpp< Key, T >::find_or_insert(), lf_hash_table::freelist, lf_hash_table_cpp< Key, T >::get_hash_table(), i, xentry::key, lf_tran_request_entry(), lf_tran_return_entry(), xentry::mutex, NO_ERROR, NOPS, NULL, PTHREAD_ABORT_AND_EXIT, RAND_BLOCK_SIZE, RAND_BLOCKS, random_numbers, success(), test_clear_proc_1(), lf_freelist::tran_system, and lf_hash_table_cpp< Key, T >::unlock().
Referenced by main().
|
static |
Definition at line 819 of file unittests_lf.c.
References lf_freelist::alloc_cnt, lf_freelist::available, lf_freelist::available_cnt, begin(), lf_hash_table::buckets, xentry::data, del_op_count, lf_hash_table_cpp< Key, T >::destroy(), lf_tran_system::entries, lf_tran_system::entry_count, lf_entry_descriptor::f_hash, fail(), lf_hash_table_cpp< Key, T >::get_freelist(), lf_hash_table_cpp< Key, T >::get_hash_table(), HASH_SIZE, i, lf_hash_table_cpp< Key, T >::init(), xentry::key, lf_tran_system_destroy(), lf_tran_system_init(), MAX_THREADS, xentry::next, NO_ERROR, NULL, lf_freelist::retired_cnt, lf_tran_entry::retired_list, xentry::stack, success(), lf_tran_entry::temp_entry, and lf_entry_descriptor::using_mutex.
Referenced by main().
|
static |
Definition at line 82 of file unittests_lf.c.
References xentry::data, xentry::mutex, NULL, and pthread_mutex_init.
|
static |
Definition at line 94 of file unittests_lf.c.
References xentry::mutex, NO_ERROR, and pthread_mutex_destroy.
|
static |
Definition at line 131 of file unittests_lf.c.
|
static |
Definition at line 102 of file unittests_lf.c.
|
static |
Definition at line 138 of file unittests_lf.c.
|
static |
Definition at line 145 of file unittests_lf.c.
References NO_ERROR.
|
static |
Definition at line 116 of file unittests_lf.c.
|
static |
Definition at line 432 of file unittests_lf.c.
Referenced by main(), test_hash_proc_3(), and test_hash_table().
|
static |
Definition at line 37 of file unittests_lf.c.
Referenced by generate_random(), test_clear_proc_1(), test_clear_proc_2(), test_clear_proc_3(), test_hash_proc_1(), test_hash_proc_2(), and test_hash_proc_3().
|
static |
Definition at line 178 of file unittests_lf.c.
|
static |
Definition at line 155 of file unittests_lf.c.