Browse Source
refs #5418 merge promotion to main
refs #5418 merge promotion to main
git-svn-id: file:///svn/toku/tokudb@49697 c7de825b-a66e-492c-adef-691d508d4ae1pull/73/head
committed by
Yoni Fogel
104 changed files with 1982 additions and 991 deletions
-
1CTestCustom.cmake
-
7cmake_modules/TokuFeatureDetection.cmake
-
8cmake_modules/TokuSetupCompiler.cmake
-
3db-benchmark-test/ptquery.cc
-
136ft/block_table.cc
-
3ft/cachetable-internal.h
-
151ft/cachetable.cc
-
12ft/cachetable.h
-
9ft/checkpoint.cc
-
14ft/fifo.cc
-
30ft/fifo.h
-
13ft/ft-cachetable-wrappers.cc
-
4ft/ft-cachetable-wrappers.h
-
332ft/ft-flusher.cc
-
1ft/ft-flusher.h
-
7ft/ft-hot-flusher.cc
-
123ft/ft-internal.h
-
949ft/ft-ops.cc
-
28ft/ft-serialize.cc
-
7ft/ft-test-helpers.cc
-
25ft/ft-verify.cc
-
10ft/ft.cc
-
1ft/ft_layout_version.h
-
109ft/ft_node-serialize.cc
-
6ft/fttypes.h
-
10ft/leafentry.h
-
5ft/locking-benchmarks/mfence-benchmark.cc
-
5ft/locking-benchmarks/pthread-locks.cc
-
7ft/locking-benchmarks/trylock-rdtsc.cc
-
1ft/rollback-ct-callbacks.h
-
2ft/rollback.cc
-
7ft/tests/cachetable-checkpoint-pending.cc
-
2ft/tests/cachetable-checkpoint-test.cc
-
5ft/tests/cachetable-checkpointer-class.cc
-
3ft/tests/cachetable-count-pinned-test.cc
-
8ft/tests/cachetable-flush-test.cc
-
2ft/tests/cachetable-prefetch-checkpoint-test.cc
-
2ft/tests/cachetable-prefetch-maybegetandpin-test.cc
-
2ft/tests/cachetable-prefetch2-test.cc
-
2ft/tests/cachetable-put-test.cc
-
18ft/tests/cachetable-simple-maybe-get-pin.cc
-
2ft/tests/cachetable-test.cc
-
2ft/tests/cachetable-unpin-and-remove-test.cc
-
2ft/tests/cachetable-unpin-test.cc
-
5ft/tests/cachetable-writer-thread-limit.cc
-
9ft/tests/ftloader-error-injector.h
-
4ft/tests/keyrange.cc
-
2ft/tests/make-tree.cc
-
16ft/tests/msnfilter.cc
-
8ft/tests/orthopush-flush.cc
-
3ft/tests/test.h
-
12ft/tests/test3884.cc
-
6ft/ule-internal.h
-
48ft/ule.cc
-
14ft/ule.h
-
5ft/worker-thread-benchmarks/threadpool.cc
-
15portability/file.cc
-
39portability/memory.cc
-
1portability/portability.cc
-
1portability/tests/CMakeLists.txt
-
88portability/tests/test-cache-line-boundary-fails.cc
-
7portability/tests/test-fair-rwlock.cc
-
4portability/tests/test-flock.cc
-
77portability/toku_atomic.h
-
23portability/toku_fair_rwlock.cc
-
9portability/toku_fair_rwlock.h
-
4src/indexer-undo-do.cc
-
21src/indexer.cc
-
17src/loader.cc
-
11src/lock_tree/locktree.cc
-
5src/tests/bdb-simple-deadlock-detect.cc
-
5src/tests/bdb-simple-deadlock-on-the-fly.cc
-
5src/tests/checkpoint_fairness.cc
-
3src/tests/db-put-update-deadlock.cc
-
5src/tests/diskfull.cc
-
2src/tests/multiprocess.cc
-
1src/tests/perf_insert.cc
-
81src/tests/seqinsert.cc
-
5src/tests/stress_openclose.h
-
3src/tests/test3039.cc
-
3src/tests/test3522.cc
-
3src/tests/test3522b.cc
-
3src/tests/test3529.cc
-
3src/tests/test_4015.cc
-
54src/tests/threaded_stress_test_helpers.h
-
3src/ydb_db.cc
-
7src/ydb_txn.cc
-
5src/ydb_write.cc
-
3toku_include/config.h.in
-
12toku_include/toku_assert.h
-
20toku_include/toku_portability.h
-
3toku_include/toku_race_tools.h
-
24util/circular_buffer.cc
-
52util/frwlock.cc
-
2util/growable_array.h
-
24util/mempool.cc
-
60util/omt.cc
-
4util/omt.h
-
3util/partitioned_counter.cc
-
20util/rwlock.h
949
ft/ft-ops.cc
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,88 @@ |
|||
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
|||
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
|
|||
#ident "$Id$"
|
|||
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
|
|||
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
|
|||
|
|||
#include <config.h>
|
|||
#include <memory.h>
|
|||
#include <portability/toku_atomic.h>
|
|||
#include "test.h"
|
|||
#include <stdint.h>
|
|||
#include <stdio.h>
|
|||
#include <stdlib.h>
|
|||
#include <signal.h>
|
|||
|
|||
int verbose = 0; |
|||
|
|||
static const size_t cachelinesize = 64; |
|||
|
|||
// cache line is 64 bytes
|
|||
// nine 7-byte structs fill 63 bytes
|
|||
// the tenth spans one byte of the first cache line and six of the next cache line
|
|||
// we first SFAA the first 9 structs and ensure we don't crash, then we set a signal handler and SFAA the 10th and ensure we do crash
|
|||
|
|||
struct unpackedsevenbytestruct { |
|||
uint32_t i; |
|||
char pad[3]; |
|||
}; |
|||
struct __attribute__((packed)) packedsevenbytestruct { |
|||
uint32_t i; |
|||
char pad[3]; |
|||
}; |
|||
|
|||
struct packedsevenbytestruct *psevenbytestructs; |
|||
static __attribute__((__noreturn__)) void catch_abort (int sig __attribute__((__unused__))) { |
|||
toku_free(psevenbytestructs); |
|||
#ifdef TOKU_DEBUG_PARANOID
|
|||
exit(EXIT_SUCCESS); // with paranoid asserts, we expect to assert and reach this handler
|
|||
#else
|
|||
exit(EXIT_FAILURE); // we should not have crashed without paranoid asserts
|
|||
#endif
|
|||
} |
|||
|
|||
int test_main(int UU(argc), char *const argv[] UU()) { |
|||
if (sizeof(unpackedsevenbytestruct) != 8) { |
|||
exit(EXIT_FAILURE); |
|||
} |
|||
if (sizeof(packedsevenbytestruct) != 7) { |
|||
exit(EXIT_FAILURE); |
|||
} |
|||
|
|||
{ |
|||
struct unpackedsevenbytestruct *usevenbytestructs; |
|||
int r = posix_memalign((void **) &usevenbytestructs, cachelinesize, sizeof(unpackedsevenbytestruct) * 10); |
|||
if (r) { |
|||
// this test is supposed to crash, so exiting cleanly is a failure
|
|||
perror("posix_memalign"); |
|||
exit(EXIT_FAILURE); |
|||
} |
|||
|
|||
for (int idx = 0; idx < 10; ++idx) { |
|||
usevenbytestructs[idx].i = idx + 1; |
|||
(void) toku_sync_fetch_and_add(&usevenbytestructs[idx].i, 32U - idx); |
|||
} |
|||
toku_free(usevenbytestructs); |
|||
} |
|||
|
|||
int r = posix_memalign((void **) &psevenbytestructs, cachelinesize, sizeof(packedsevenbytestruct) * 10); |
|||
if (r) { |
|||
// this test is supposed to crash, so exiting cleanly is a failure
|
|||
perror("posix_memalign"); |
|||
exit(EXIT_FAILURE); |
|||
} |
|||
|
|||
for (int idx = 0; idx < 9; ++idx) { |
|||
psevenbytestructs[idx].i = idx + 1; |
|||
(void) toku_sync_fetch_and_add(&psevenbytestructs[idx].i, 32U - idx); |
|||
} |
|||
psevenbytestructs[9].i = 10; |
|||
signal(SIGABRT, catch_abort); |
|||
(void) toku_sync_fetch_and_add(&psevenbytestructs[9].i, 32U); |
|||
|
|||
#ifdef TOKU_DEBUG_PARANOID
|
|||
exit(EXIT_FAILURE); // with paranoid asserts, we should already have crashed
|
|||
#else
|
|||
exit(EXIT_SUCCESS); // without them, we should make it here
|
|||
#endif
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
|||
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
|||
#ident "Copyright (c) 2012 Tokutek Inc. All rights reserved." |
|||
#ident "$Id$" |
|||
|
|||
#ifndef TOKU_ATOMIC_H |
|||
#define TOKU_ATOMIC_H |
|||
|
|||
#include <config.h> |
|||
#include <toku_assert.h> |
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include <stddef.h> |
|||
|
|||
__attribute__((const, always_inline)) |
|||
static inline intptr_t which_cache_line(intptr_t addr) { |
|||
static const size_t assumed_cache_line_size = 64; |
|||
return addr / assumed_cache_line_size; |
|||
} |
|||
template <typename T> __attribute__((const, always_inline)) |
|||
static inline bool crosses_boundary(T *addr, size_t width) { |
|||
const intptr_t int_addr = reinterpret_cast<intptr_t>(addr); |
|||
const intptr_t last_byte = int_addr + width - 1; |
|||
return which_cache_line(int_addr) != which_cache_line(last_byte); |
|||
} |
|||
|
|||
template <typename T, typename U> __attribute__((always_inline)) |
|||
static inline T toku_sync_fetch_and_add(T *addr, U diff) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_fetch_and_add(addr, diff); |
|||
} |
|||
template <typename T, typename U> __attribute__((always_inline)) |
|||
static inline T toku_sync_add_and_fetch(T *addr, U diff) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_add_and_fetch(addr, diff); |
|||
} |
|||
template <typename T, typename U> __attribute__((always_inline)) |
|||
static inline T toku_sync_fetch_and_sub(T *addr, U diff) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_fetch_and_sub(addr, diff); |
|||
} |
|||
template <typename T, typename U> __attribute__((always_inline)) |
|||
static inline T toku_sync_sub_and_fetch(T *addr, U diff) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_sub_and_fetch(addr, diff); |
|||
} |
|||
template <typename T, typename U, typename V> __attribute__((always_inline)) |
|||
static inline T toku_sync_val_compare_and_swap(T *addr, U oldval, V newval) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_val_compare_and_swap(addr, oldval, newval); |
|||
} |
|||
template <typename T, typename U, typename V> __attribute__((always_inline)) |
|||
static inline bool toku_sync_bool_compare_and_swap(T *addr, U oldval, V newval) { |
|||
paranoid_invariant(!crosses_boundary(addr, sizeof *addr)); |
|||
return __sync_bool_compare_and_swap(addr, oldval, newval); |
|||
} |
|||
|
|||
// in case you include this but not toku_portability.h |
|||
#pragma GCC poison __sync_fetch_and_add |
|||
#pragma GCC poison __sync_fetch_and_sub |
|||
#pragma GCC poison __sync_fetch_and_or |
|||
#pragma GCC poison __sync_fetch_and_and |
|||
#pragma GCC poison __sync_fetch_and_xor |
|||
#pragma GCC poison __sync_fetch_and_nand |
|||
#pragma GCC poison __sync_add_and_fetch |
|||
#pragma GCC poison __sync_sub_and_fetch |
|||
#pragma GCC poison __sync_or_and_fetch |
|||
#pragma GCC poison __sync_and_and_fetch |
|||
#pragma GCC poison __sync_xor_and_fetch |
|||
#pragma GCC poison __sync_nand_and_fetch |
|||
#pragma GCC poison __sync_bool_compare_and_swap |
|||
#pragma GCC poison __sync_val_compare_and_swap |
|||
#pragma GCC poison __sync_synchronize |
|||
#pragma GCC poison __sync_lock_test_and_set |
|||
#pragma GCC poison __sync_release |
|||
|
|||
#endif // TOKU_ATOMIC_H |
|||
@ -0,0 +1,81 @@ |
|||
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
|||
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
|
|||
#ident "$Id$"
|
|||
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
|
|||
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
|
|||
|
|||
#include "test.h"
|
|||
#include <db.h>
|
|||
#include <toku_portability.h>
|
|||
#include <toku_os.h>
|
|||
#include <memory.h>
|
|||
#include <stdint.h>
|
|||
#include <stdlib.h>
|
|||
|
|||
DB_TXN * const null_txn = nullptr; |
|||
|
|||
const size_t nodesize = 128 << 10; |
|||
const size_t keysize = 8; |
|||
const size_t valsize = 92; |
|||
const size_t rowsize = keysize + valsize; |
|||
const int max_degree = 16; |
|||
const size_t numleaves = max_degree * 3; // want height 2, this should be good enough
|
|||
const size_t numrows = (numleaves * nodesize + rowsize) / rowsize; |
|||
|
|||
static void test_seqinsert(bool asc) { |
|||
int r; |
|||
r = system("rm -rf " ENVDIR); |
|||
CKERR(r); |
|||
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); |
|||
CKERR(r); |
|||
|
|||
DB_ENV *env; |
|||
r = db_env_create(&env, 0); |
|||
CKERR(r); |
|||
r = env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); |
|||
CKERR(r); |
|||
|
|||
DB *db; |
|||
r = db_create(&db, env, 0); |
|||
CKERR(r); |
|||
r = db->set_pagesize(db, nodesize); |
|||
CKERR(r); |
|||
r = db->open(db, null_txn, "seqinsert", NULL, DB_BTREE, DB_CREATE, 0666); |
|||
CKERR(r); |
|||
|
|||
{ |
|||
DB_TXN *txn; |
|||
r = env->txn_begin(env, 0, &txn, 0); |
|||
CKERR(r); |
|||
|
|||
char v[valsize]; |
|||
ZERO_ARRAY(v); |
|||
uint64_t k; |
|||
DBT key, val; |
|||
dbt_init(&key, &k, sizeof k); |
|||
dbt_init(&val, v, valsize); |
|||
for (size_t i = 0; i < numrows; ++i) { |
|||
k = toku_htod64(numrows + (asc ? i : -i)); |
|||
r = db->put(db, txn, &key, &val, 0); |
|||
CKERR(r); |
|||
} |
|||
|
|||
r = txn->commit(txn, 0); |
|||
CKERR(r); |
|||
} |
|||
|
|||
r = db->close(db, 0); |
|||
CKERR(r); |
|||
|
|||
r = env->close(env, 0); |
|||
CKERR(r); |
|||
} |
|||
|
|||
int test_main(int argc, char * const argv[]) { |
|||
default_parse_args(argc, argv); |
|||
|
|||
test_seqinsert(true); |
|||
test_seqinsert(false); |
|||
|
|||
return 0; |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue