Commit f1086d04 authored by Yoni Fogel's avatar Yoni Fogel

[t:2257] Switch atomic instructions to decrement, increment if they only modify by 1,

remove some bookkkeeping in windows that is slow and not completely necessary.

git-svn-id: file:///svn/toku/tokudb@16998 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4cf833e7
......@@ -114,7 +114,7 @@ toku_file_fsync(int fd) {
if (r)
assert(errno==EINTR);
}
toku_sync_fetch_and_add_uint64(&toku_fsync_count, 1);
toku_sync_fetch_and_increment_uint64(&toku_fsync_count);
toku_sync_fetch_and_add_uint64(&toku_fsync_time, get_tnow() - tstart);
return r;
}
......
......@@ -39,9 +39,9 @@ flush (CACHEFILE UU(thiscf), CACHEKEY UU(key), void *value, void *UU(extraargs),
int *v = value;
if (*v!=expect_value) printf("got %d expect %d\n", *v, expect_value);
assert(*v==expect_value);
(void)toku_sync_fetch_and_add_int32(&n_flush, 1);
if (write_me) (void)toku_sync_fetch_and_add_int32(&n_write_me, 1);
if (keep_me) (void)toku_sync_fetch_and_add_int32(&n_keep_me, 1);
(void)toku_sync_fetch_and_increment_int32(&n_flush);
if (write_me) (void)toku_sync_fetch_and_increment_int32(&n_write_me);
if (keep_me) (void)toku_sync_fetch_and_increment_int32(&n_keep_me);
sleep_random();
}
......
......@@ -151,7 +151,7 @@ toku_ydb_lock(void) {
memset(ydbtime, 0, sizeof (struct ydbtime));
r = toku_pthread_setspecific(ydb_big_lock.time_key, ydbtime);
assert(r == 0);
(void) toku_sync_fetch_and_add_uint64(&status.total_clients, 1);
(void) toku_sync_fetch_and_increment_uint64(&status.total_clients);
}
if (ydbtime->tacquire) { // delay the thread if the lock acquire time is set and is less than the current time
if (0) printf("%"PRIu64"\n", ydbtime->tacquire);
......@@ -162,21 +162,23 @@ toku_ydb_lock(void) {
// put an upper bound on the sleep time since the timestamps may be crazy due to thread movement between cpu's or cpu frequency changes
if (t > MAX_SLEEP) {
t = MAX_SLEEP;
(void) toku_sync_fetch_and_add_uint64(&status.times_max_sleep_used, 1);
(void) toku_sync_fetch_and_increment_uint64(&status.times_max_sleep_used);
}
#if !TOKU_WINDOWS || TOKU_WINDOWS_HAS_FAST_ATOMIC_64
(void) toku_sync_fetch_and_add_uint64(&status.total_sleep_time, t);
(void) toku_sync_fetch_and_add_uint64(&status.total_sleepers, 1);
#endif
(void) toku_sync_fetch_and_increment_uint64(&status.total_sleepers);
usleep(t);
}
}
r = toku_pthread_mutex_trylock(&ydb_big_lock.lock);
if (r != 0) { // if we can not get the lock, bump the count of the lock waits, and block on the lock
assert(r == EBUSY);
(void) toku_sync_fetch_and_add_int32(&ydb_big_lock.waiters, 1);
(void) toku_sync_fetch_and_add_uint64(&status.total_waiters, 1);
(void) toku_sync_fetch_and_increment_int32(&ydb_big_lock.waiters);
(void) toku_sync_fetch_and_increment_uint64(&status.total_waiters);
r = toku_pthread_mutex_lock(&ydb_big_lock.lock);
assert(r == 0);
(void) toku_sync_fetch_and_add_int32(&ydb_big_lock.waiters, -1);
(void) toku_sync_fetch_and_decrement_int32(&ydb_big_lock.waiters);
}
status.max_requested_sleep = u64max(status.max_requested_sleep, requested_sleep);
toku_cachetable_get_miss_times(NULL, &ydb_big_lock.start_miss_count, &ydb_big_lock.start_miss_time);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment