add a few simple multicore scalability tests

This commit is contained in:
Sears Russell 2009-10-12 22:29:10 +00:00
parent 0e93a577c9
commit 0f2ab3c37c
11 changed files with 401 additions and 0 deletions

View file

@ -1,3 +1,5 @@
SUBDIRS(multicore)
IF(HAVE_GETLINE)
ADD_EXECUTABLE(rose rose.cpp)
TARGET_LINK_LIBRARIES(rose ${COMMON_LIBRARIES})
@ -31,6 +33,7 @@ CREATE_EXECUTABLE(sequentialThroughput)
CREATE_EXECUTABLE(qos)
CREATE_EXECUTABLE(writeBack)
CREATE_EXECUTABLE(distributedLsnFree)
IF(CHECK_LIBRARY)
ADD_TEST(rose rose)
ENDIF(CHECK_LIBRARY)

View file

@ -0,0 +1,8 @@
CREATE_EXECUTABLE(smallLogEntry)
CREATE_EXECUTABLE(noopTransactions)
CREATE_EXECUTABLE(pinSamePage)
CREATE_EXECUTABLE(pinDifferentPages)
CREATE_EXECUTABLE(readLatch)
CREATE_EXECUTABLE(readLatches)
CREATE_EXECUTABLE(writeLatch)
CREATE_EXECUTABLE(writeLatches)

View file

@ -0,0 +1,22 @@
#!/usr/bin/perl -w
use strict;
my @in = `cd $ARGV[0]; ls *.c`;
my $out = $ARGV[1];
my $N = $ARGV[2];
chomp $out;
foreach my $line (@in) {
chomp $line;
$line =~ s/\..+//g;
open OUT, "> $out/$line.script";
print OUT "#!/usr/bin/env timer.pl\n";
for my $i (qw(1 2 4 8 16)) {
print OUT "./$line $i $N\n";
`chmod +x $out/$line.script`;
}
close OUT;
}

View file

@ -0,0 +1,43 @@
/*
* noopTransactions.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/transactional.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
static void* noopWorker(void* arg) {
unsigned long numops = *(unsigned long*) arg;
for(unsigned long i = 0; i < numops; i++) {
int xid = Tbegin();
TsoftCommit(xid);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
unsigned long numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
Tinit();
for(int i = 0; i < numthreads; i++) {
pthread_create(&workers[i], 0, noopWorker, &numops);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
Tdeinit();
}

View file

@ -0,0 +1,51 @@
/*
* pinDifferentPages.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/transactional.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
unsigned long numops;
static void* worker(void* arg) {
pageid_t pid = *(pageid_t*)arg;
for(unsigned long i = 0; i < numops; i++) {
Page * p = loadPage(-1, pid);
releasePage(p);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
pageid_t pids[numthreads];
Tinit();
for(int i = 0; i < numthreads; i++) {
pids[i] = i;
pthread_create(&workers[i], 0, worker, &pids[i]);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
Tdeinit();
}

View file

@ -0,0 +1,49 @@
/*
* pinSamePage.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/transactional.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
stasis_log_t * l;
static void* worker(void* arg) {
unsigned long numops = *(unsigned long*) arg;
for(unsigned long i = 0; i < numops; i++) {
Page * p = loadPage(-1, 0);
releasePage(p);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
unsigned long numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
Tinit();
for(int i = 0; i < numthreads; i++) {
pthread_create(&workers[i], 0, worker, &numops);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
Tdeinit();
}

View file

@ -0,0 +1,38 @@
#include <stasis/rw.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
rwl * l;
static void* worker(void* arg) {
unsigned long numops = *(unsigned long*) arg;
for(unsigned long i = 0; i < numops; i++) {
readlock(l, 0);
unlock(l);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
unsigned long numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
l = initlock();
for(int i = 0; i < numthreads; i++) {
pthread_create(&workers[i], 0, worker, &numops);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
}

View file

@ -0,0 +1,44 @@
/*
* uncontestedReadLatches.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/rw.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
unsigned long numops;
static void* worker(void* arg) {
rwl * l = arg;
for(unsigned long i = 0; i < numops; i++) {
readlock(l, 0);
unlock(l);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
rwl * l[numthreads];
for(int i = 0; i < numthreads; i++) {
l[i] = initlock();
pthread_create(&workers[i], 0, worker, l[i]);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
}

View file

@ -0,0 +1,55 @@
/*
* smallLogEntry.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/logger/logger2.h>
#include <stasis/logger/safeWrites.h>
#include <stasis/flags.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
stasis_log_t * l;
static void* worker(void* arg) {
unsigned long numops = *(unsigned long*) arg;
LogEntry e;
e.LSN = 0;
e.prevLSN = 0;
e.type = UPDATELOG;
e.xid = 0;
e.update.arg_size = 0;
e.update.funcID = 0;
e.update.page = INVALID_PAGE;
for(unsigned long i = 0; i < numops; i++) {
l->write_entry(l, &e);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
unsigned long numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
l = stasis_log_safe_writes_open(stasis_log_file_name, stasis_log_file_mode, stasis_log_file_permissions, 0);
for(int i = 0; i < numthreads; i++) {
pthread_create(&workers[i], 0, worker, &numops);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
}

View file

@ -0,0 +1,44 @@
/*
* writeLatch.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/rw.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
rwl * l;
static void* worker(void* arg) {
unsigned long numops = *(unsigned long*) arg;
for(unsigned long i = 0; i < numops; i++) {
writelock(l, 0);
unlock(l);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
unsigned long numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
l = initlock();
for(int i = 0; i < numthreads; i++) {
pthread_create(&workers[i], 0, worker, &numops);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
}

View file

@ -0,0 +1,44 @@
/*
* writeLatches.c
*
* Created on: Oct 12, 2009
* Author: sears
*/
#include <stasis/rw.h>
#include <pthread.h>
#include <stdio.h>
char * usage = "%s numthreads numops\n";
unsigned long numops;
static void* worker(void* arg) {
rwl * l = arg;
for(unsigned long i = 0; i < numops; i++) {
writelock(l, 0);
unlock(l);
}
return 0;
}
int main(int argc, char * argv[]) {
if(argc != 3) { printf(usage, argv[0]); abort(); }
char * endptr;
unsigned long numthreads = strtoul(argv[1], &endptr, 10);
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
numops= strtoul(argv[2], &endptr, 10) / numthreads;
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
pthread_t workers[numthreads];
rwl * l[numthreads];
for(int i = 0; i < numthreads; i++) {
l[i] = initlock();
pthread_create(&workers[i], 0, worker, l[i]);
}
for(int i = 0; i < numthreads; i++) {
pthread_join(workers[i], 0);
}
}