ck_rw_cohort: Added benchmark tests for reader-writer cohort locks

ck_pring
Brendon Scheinman 12 years ago
parent f693a16253
commit 0d20391563

8
.gitignore vendored

@ -146,5 +146,9 @@ regressions/ck_cohort/benchmark/ck_cohort.THROUGHPUT
regressions/ck_rw_cohort/validate/ck_neutral
regressions/ck_rw_cohort/validate/ck_rp
regressions/ck_rw_cohort/validate/ck_wp
regressions/ck_rw_cohort/benchmark/latency
regressions/ck_rw_cohort/benchmark/throughput
regressions/ck_rw_cohort/benchmark/ck_neutral.LATENCY
regressions/ck_rw_cohort/benchmark/ck_neutral.THROUGHPUT
regressions/ck_rw_cohort/benchmark/ck_rp.LATENCY
regressions/ck_rw_cohort/benchmark/ck_rp.THROUGHPUT
regressions/ck_rw_cohort/benchmark/ck_wp.LATENCY
regressions/ck_rw_cohort/benchmark/ck_wp.THROUGHPUT

@ -236,7 +236,7 @@
#define CK_RW_COHORT_NEUTRAL_NAME(N) ck_rw_cohort_neutral_##N
#define CK_RW_COHORT_NEUTRAL_INSTANCE(N) struct CK_RW_COHORT_NEUTRAL_NAME(N)
#define CK_RW_COHORT_NEUTRAL_INIT(N, RW, WL) ck_rw_cohort_neutral_##N##_init(RW, WL)
#define CK_RW_COHORT_NEUTRAL_INIT(N, RW) ck_rw_cohort_neutral_##N##_init(RW)
#define CK_RW_COHORT_NEUTRAL_READ_LOCK(N, RW, C, GC, LC) ck_rw_cohort_neutral_##N##_read_lock(RW, C, GC, LC)
#define CK_RW_COHORT_NEUTRAL_READ_UNLOCK(N, RW, C, GC, LC) ck_rw_cohort_neutral_##N##_read_unlock(RW)
#define CK_RW_COHORT_NEUTRAL_WRITE_LOCK(N, RW, C, GC, LC) ck_rw_cohort_neutral_##N##_write_lock(RW, C, GC, LC)

@ -1,14 +1,29 @@
.PHONY: clean distribution
OBJECTS=latency throughput
OBJECTS=ck_neutral.THROUGHPUT ck_neutral.LATENCY \
ck_rp.THROUGHPUT ck_rp.LATENCY \
ck_wp.THROUGHPUT ck_wp.LATENCY
all: $(OBJECTS)
latency: latency.c ../../../include/ck_rw_cohort.h
$(CC) $(CFLAGS) -o latency latency.c
ck_neutral.THROUGHPUT: ck_neutral.c
$(CC) -DTHROUGHPUT $(CFLAGS) -o ck_neutral.THROUGHPUT ck_neutral.c
throughput: throughput.c ../../../include/ck_rw_cohort.h
$(CC) $(CFLAGS) -o throughput throughput.c
ck_neutral.LATENCY: ck_neutral.c
$(CC) -DLATENCY $(CFLAGS) -o ck_neutral.LATENCY ck_neutral.c
ck_rp.THROUGHPUT: ck_rp.c
$(CC) -DTHROUGHPUT $(CFLAGS) -o ck_rp.THROUGHPUT ck_rp.c
ck_rp.LATENCY: ck_rp.c
$(CC) -DLATENCY $(CFLAGS) -o ck_rp.LATENCY ck_rp.c
ck_wp.THROUGHPUT: ck_wp.c
$(CC) -DTHROUGHPUT $(CFLAGS) -o ck_wp.THROUGHPUT ck_wp.c
ck_wp.LATENCY: ck_wp.c
$(CC) -DLATENCY $(CFLAGS) -o ck_wp.LATENCY ck_wp.c
clean:
rm -rf *.dSYM *~ *.o $(OBJECTS)

@ -0,0 +1,7 @@
#include "../ck_neutral.h"
#ifdef THROUGHPUT
#include "throughput.h"
#elif defined(LATENCY)
#include "latency.h"
#endif

@ -0,0 +1,7 @@
#include "../ck_rp.h"
#ifdef THROUGHPUT
#include "throughput.h"
#elif defined(LATENCY)
#include "latency.h"
#endif

@ -0,0 +1,7 @@
#include "../ck_wp.h"
#ifdef THROUGHPUT
#include "throughput.h"
#elif defined(LATENCY)
#include "latency.h"
#endif

@ -60,7 +60,7 @@ ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context)
CK_COHORT_PROTOTYPE(fas_fas,
ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context,
ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context)
CK_RW_COHORT_WP_PROTOTYPE(fas_fas)
LOCK_PROTOTYPE(fas_fas)
int
main(void)
@ -69,34 +69,34 @@ main(void)
ck_spinlock_fas_t global_lock = CK_SPINLOCK_FAS_INITIALIZER;
ck_spinlock_fas_t local_lock = CK_SPINLOCK_FAS_INITIALIZER;
CK_COHORT_INSTANCE(fas_fas) cohort = CK_COHORT_INITIALIZER;
CK_RW_COHORT_WP_INSTANCE(fas_fas) rw_cohort = CK_RW_COHORT_WP_INITIALIZER;
LOCK_INSTANCE(fas_fas) rw_cohort = LOCK_INITIALIZER;
CK_COHORT_INIT(fas_fas, &cohort, &global_lock, &local_lock,
CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT);
CK_RW_COHORT_WP_INIT(fas_fas, &rw_cohort, CK_RW_COHORT_WP_DEFAULT_WAIT_LIMIT);
LOCK_INIT(fas_fas, &rw_cohort, CK_RW_COHORT_WP_DEFAULT_WAIT_LIMIT);
for (i = 0; i < STEPS; i++) {
CK_RW_COHORT_WP_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
CK_RW_COHORT_WP_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
}
s_b = rdtsc();
for (i = 0; i < STEPS; i++) {
CK_RW_COHORT_WP_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
CK_RW_COHORT_WP_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
}
e_b = rdtsc();
printf("WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS);
for (i = 0; i < STEPS; i++) {
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
}
s_b = rdtsc();
for (i = 0; i < STEPS; i++) {
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL);
}
e_b = rdtsc();
printf("READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS);

@ -78,7 +78,7 @@ ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context)
CK_COHORT_PROTOTYPE(fas_fas,
ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context,
ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context)
CK_RW_COHORT_WP_PROTOTYPE(fas_fas)
LOCK_PROTOTYPE(fas_fas)
struct cohort_record {
CK_COHORT_INSTANCE(fas_fas) cohort;
@ -86,7 +86,7 @@ struct cohort_record {
static struct cohort_record *cohorts;
static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER;
static CK_RW_COHORT_WP_INSTANCE(fas_fas) rw_cohort = CK_RW_COHORT_WP_INITIALIZER;
static LOCK_INSTANCE(fas_fas) rw_cohort = LOCK_INITIALIZER;
static unsigned int n_cohorts;
struct block {
@ -114,38 +114,38 @@ thread_rwlock(void *pun)
for (i = 1, a = 0;; i++) {
s_b = rdtsc();
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
CK_RW_COHORT_WP_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
CK_RW_COHORT_WP_READ_UNLOCK(fas_fas, &rw_cohort);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL);
e_b = rdtsc();
a += (e_b - s_b) >> 4;

@ -1,6 +1,7 @@
#define LOCK_PROTOTYPE CK_RW_COHORT_NEUTRAL_PROTOTYPE
#define LOCK_INSTANCE CK_RW_COHORT_NEUTRAL_INSTANCE
#define LOCK_INITIALIZER CK_RW_COHORT_NEUTRAL_INITIALIZER
#define LOCK_INIT(N, C, W) CK_RW_COHORT_NEUTRAL_INIT(N, C)
#define READ_LOCK CK_RW_COHORT_NEUTRAL_READ_LOCK
#define WRITE_LOCK CK_RW_COHORT_NEUTRAL_WRITE_LOCK
#define READ_UNLOCK CK_RW_COHORT_NEUTRAL_READ_UNLOCK

@ -1,6 +1,7 @@
#define LOCK_PROTOTYPE CK_RW_COHORT_RP_PROTOTYPE
#define LOCK_INSTANCE CK_RW_COHORT_RP_INSTANCE
#define LOCK_INITIALIZER CK_RW_COHORT_RP_INITIALIZER
#define LOCK_INIT CK_RW_COHORT_RP_INIT
#define READ_LOCK CK_RW_COHORT_RP_READ_LOCK
#define READ_UNLOCK CK_RW_COHORT_RP_READ_UNLOCK
#define WRITE_LOCK CK_RW_COHORT_RP_WRITE_LOCK

@ -1,17 +1,8 @@
#define LOCK_PROTOTYPE CK_RW_COHORT_WP_PROTOTYPE
#define LOCK_INSTANCE CK_RW_COHORT_WP_INSTANCE
#define LOCK_INITIALIZER CK_RW_COHORT_WP_INITIALIZER
#define LOCK_INIT CK_RW_COHORT_WP_INIT
#define READ_LOCK CK_RW_COHORT_WP_READ_LOCK
#define WRITE_LOCK CK_RW_COHORT_WP_WRITE_LOCK
#define READ_UNLOCK CK_RW_COHORT_WP_READ_UNLOCK
#define WRITE_UNLOCK CK_RW_COHORT_WP_WRITE_UNLOCK
/*
#define WRITE_LOCK(N, RW, C, GC, LC)\
CK_RW_COHORT_WP_WRITE_LOCK(N, RW, C, GC, LC)
#define WRITE_UNLOCK(N, RW, C, GC, LC)\
CK_RW_COHORT_WP_WRITE_UNLOCK(N, RW, C, GC, LC);
#define READ_LOCK(N, RW, C, GC, LC)\
CK_RW_COHORT_WP_READ_LOCK(N, RW)
*/
Loading…
Cancel
Save