void do_tests() { plan(4); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); my_atomic_rwlock_init(&rwl); b32= c32= 0; test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES); b32= c32= 0; test_concurrently("my_atomic_fas32", test_atomic_fas, THREADS, CYCLES); b32= c32= 0; test_concurrently("my_atomic_cas32", test_atomic_cas, THREADS, CYCLES); my_atomic_rwlock_destroy(&rwl); }
void do_tests() { plan(4); lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used)); lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0, &my_charset_bin); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); test_concurrently("lf_pinbox", test_lf_pinbox, N= THREADS, CYCLES); test_concurrently("lf_alloc", test_lf_alloc, N= THREADS, CYCLES); test_concurrently("lf_hash", test_lf_hash, N= THREADS, CYCLES/10); lf_hash_destroy(&lf_hash); lf_alloc_destroy(&lf_allocator); }
void do_tests() { plan(6); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); my_atomic_rwlock_init(&rwl); b32= c32= 0; test_concurrently("my_atomic_add32", test_atomic_add, THREADS, CYCLES); b32= c32= 0; test_concurrently("my_atomic_fas32", test_atomic_fas, THREADS, CYCLES); b32= c32= 0; test_concurrently("my_atomic_cas32", test_atomic_cas, THREADS, CYCLES); { /* If b is not volatile, the wrong assembly code is generated on OSX Lion as the variable is optimized away as a constant. See Bug#62533 / Bug#13030056. Another workaround is to specify architecture explicitly using e.g. CFLAGS/CXXFLAGS= "-m64". */ volatile int64 b=0x1000200030004000LL; a64=0; my_atomic_add64(&a64, b); ok(a64==b, "add64"); } a64=0; test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES); my_atomic_rwlock_destroy(&rwl); /* workaround until we know why it crashes randomly on some machine (BUG#22320). */ sleep(2); }
int main(int argc __attribute__((unused)), char **argv) { MY_INIT(argv[0]); plan(7); if (my_atomic_initialize()) return exit_status(); pthread_mutex_init(&rt_mutex, 0); pthread_attr_init(&attr); #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE pthread_attr_getstacksize(&attr, &stacksize); if (stacksize == 0) #endif stacksize= PTHREAD_STACK_MIN; #define CYCLES 10000 #define THREADS 10 trnman_init(0); test_trnman_read_from(); run_test("trnman", test_trnman, THREADS, CYCLES); diag("mallocs: %d", trnman_allocated_transactions); { ulonglong now= microsecond_interval_timer(); trnman_destroy(); now= microsecond_interval_timer() - now; diag("trnman_destroy: %g", ((double)now)/1e6); } pthread_mutex_destroy(&rt_mutex); my_end(0); return exit_status(); }
int main(int argc __attribute__((unused)), char **argv) { int i; MY_INIT(argv[0]); my_init(); pthread_mutex_init(&rt_mutex, 0); plan(40); if (my_atomic_initialize()) return exit_status(); tablockman_init(&tablockman, &loid2lo1, 50); for (i= 0; i < Nlos; i++) { pthread_mutex_init(&mutexes[i], MY_MUTEX_INIT_FAST); pthread_cond_init (&conds[i], 0); loarray1[i].active_locks= 0; loarray1[i].waiting_lock= 0; loarray1[i].waiting_for= 0; loarray1[i].mutex= &mutexes[i]; loarray1[i].cond= &conds[i]; loarray1[i].loid= i+1; } for (i= 0; i < Ntbls; i++) { tablockman_init_locked_table(ltarray+i, Nlos); } test_tablockman_simple(); #define CYCLES 10000 #define THREADS Nlos /* don't change this line */ /* mixed load, stress-test with random locks */ Nrows= 100; Ntables= 10; table_lock_ratio= 10; run_test("\"random lock\" stress test", test_lockman, THREADS, CYCLES); #if 0 /* "real-life" simulation - many rows, no table locks */ Nrows= 1000000; Ntables= 10; table_lock_ratio= 0; run_test("\"real-life\" simulation test", test_lockman, THREADS, CYCLES*10); #endif for (i= 0; i < Nlos; i++) { tablockman_release_locks(&tablockman, &loarray1[i]); pthread_mutex_destroy(loarray1[i].mutex); pthread_cond_destroy(loarray1[i].cond); } { ulonglong now= my_getsystime(); for (i= 0; i < Ntbls; i++) { tablockman_destroy_locked_table(ltarray+i); } tablockman_destroy(&tablockman); now= my_getsystime()-now; diag("lockman_destroy: %g secs", ((double)now)/1e7); } pthread_mutex_destroy(&rt_mutex); my_end(0); return exit_status(); }
void do_tests() { DBUG_ENTER("do_tests"); skip_all(": this module is not used in MySQL"); plan(12); compile_time_assert(THREADS >= 4); DBUG_PRINT("wt", ("================= initialization ===================")); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); mysql_cond_init(0, &thread_sync, 0); mysql_mutex_init(0, &lock, 0); wt_init(); for (cnt=0; cnt < THREADS; cnt++) mysql_mutex_init(0, & thds[cnt].lock, 0); { WT_RESOURCE_ID resid[4]; for (i=0; i < array_elements(resid); i++) { wt_thd_lazy_init(& thds[i].thd, & wt_deadlock_search_depth_short, & wt_timeout_short, & wt_deadlock_search_depth_long, & wt_timeout_long); resid[i].value= i+1; resid[i].type= &restype; } DBUG_PRINT("wt", ("================= manual test ===================")); #define ok_wait(X,Y, R) \ ok(wt_thd_will_wait_for(& thds[X].thd, & thds[Y].thd, &resid[R]) == 0, \ "thd[" #X "] will wait for thd[" #Y "]") #define ok_deadlock(X,Y,R) \ ok(wt_thd_will_wait_for(& thds[X].thd, & thds[Y].thd, &resid[R]) == WT_DEADLOCK, \ "thd[" #X "] will wait for thd[" #Y "] - deadlock") ok_wait(0,1,0); ok_wait(0,2,0); ok_wait(0,3,0); mysql_mutex_lock(&lock); bad= wt_thd_cond_timedwait(& thds[0].thd, &lock); mysql_mutex_unlock(&lock); ok(bad == WT_TIMEOUT, "timeout test returned %d", bad); ok_wait(0,1,0); ok_wait(1,2,1); ok_deadlock(2,0,2); mysql_mutex_lock(&lock); ok(wt_thd_cond_timedwait(& thds[0].thd, &lock) == WT_TIMEOUT, "as always"); ok(wt_thd_cond_timedwait(& thds[1].thd, &lock) == WT_TIMEOUT, "as always"); wt_thd_release_all(& thds[0].thd); wt_thd_release_all(& thds[1].thd); wt_thd_release_all(& thds[2].thd); wt_thd_release_all(& thds[3].thd); for (i=0; i < array_elements(resid); i++) { wt_thd_release_all(& thds[i].thd); wt_thd_destroy(& thds[i].thd); } mysql_mutex_unlock(&lock); } wt_deadlock_search_depth_short=6; wt_timeout_short=1000; wt_timeout_long= 100; wt_deadlock_search_depth_long=16; DBUG_PRINT("wt", ("================= stress test ===================")); diag("timeout_short=%lu us, deadlock_search_depth_short=%lu", wt_timeout_short, wt_deadlock_search_depth_short); diag("timeout_long=%lu us, deadlock_search_depth_long=%lu", wt_timeout_long, wt_deadlock_search_depth_long); #define test_kill_strategy(X) \ diag("kill strategy: " #X); \ DBUG_EXECUTE("reset_file", \ { rewind(DBUG_FILE); my_chsize(fileno(DBUG_FILE), 0, 0, MYF(0)); }); \ DBUG_PRINT("info", ("kill strategy: " #X)); \ kill_strategy=X; \ do_one_test(); test_kill_strategy(LATEST); test_kill_strategy(RANDOM); /* these two take looong time on sol10-amd64-a the server doesn't use this code now, so we disable these tests test_kill_strategy(YOUNGEST); test_kill_strategy(LOCKS); */ DBUG_PRINT("wt", ("================= cleanup ===================")); for (cnt=0; cnt < THREADS; cnt++) mysql_mutex_destroy(& thds[cnt].lock); wt_end(); mysql_mutex_destroy(&lock); mysql_cond_destroy(&thread_sync); DBUG_VOID_RETURN; }