From fbdc0f04995bc5932a8ad83596c9c53284e8fdcf Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Tue, 13 Oct 2009 01:50:35 +0000 Subject: [PATCH] more benchmarks, add support for in memory log to the smallLogEntry benchmark --- benchmarks/multicore/CMakeLists.txt | 2 + benchmarks/multicore/dirtyPage.c | 55 +++++++++++++++++++++++++ benchmarks/multicore/dirtyPages.c | 61 ++++++++++++++++++++++++++++ benchmarks/multicore/smallLogEntry.c | 9 ++-- 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 benchmarks/multicore/dirtyPage.c create mode 100644 benchmarks/multicore/dirtyPages.c diff --git a/benchmarks/multicore/CMakeLists.txt b/benchmarks/multicore/CMakeLists.txt index cc823f0..6d78edd 100644 --- a/benchmarks/multicore/CMakeLists.txt +++ b/benchmarks/multicore/CMakeLists.txt @@ -1,3 +1,5 @@ +CREATE_EXECUTABLE(dirtyPages) +CREATE_EXECUTABLE(dirtyPage) CREATE_EXECUTABLE(smallLogEntry) CREATE_EXECUTABLE(noopTransactions) CREATE_EXECUTABLE(pinSamePage) diff --git a/benchmarks/multicore/dirtyPage.c b/benchmarks/multicore/dirtyPage.c new file mode 100644 index 0000000..1aa3257 --- /dev/null +++ b/benchmarks/multicore/dirtyPage.c @@ -0,0 +1,55 @@ +/* + * dirtyPage.c + * + * Created on: Oct 12, 2009 + * Author: sears + */ + +#include +#include +#include + +char * usage = "%s numthreads numops\n"; + +stasis_dirty_page_table_t * dpt; + +unsigned long numops; +unsigned long numthreads; +Page ** p; + +static void* worker(void* arg) { + Page * p = arg; + for(unsigned long i = 0; i < numops; i++) { + stasis_dirty_page_table_set_dirty(dpt, p); + } + return 0; +} + +int main(int argc, char * argv[]) { + if(argc != 3) { printf(usage, argv[0]); abort(); } + char * endptr; + 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]; + + Page * p; + Tinit(); + + dpt = stasis_runtime_dirty_page_table(); + + p = loadPage(-1,0); + + for(int i = 0; i < numthreads; i++) { + pthread_create(&workers[i], 0, worker, p); + } + for(int i = 0; i < numthreads; i++) { + pthread_join(workers[i], 0); + } + + releasePage(p); + + Tdeinit(); +} diff --git a/benchmarks/multicore/dirtyPages.c b/benchmarks/multicore/dirtyPages.c new file mode 100644 index 0000000..05da86f --- /dev/null +++ b/benchmarks/multicore/dirtyPages.c @@ -0,0 +1,61 @@ +/* + * dirtyPages.c + * + * Created on: Oct 12, 2009 + * Author: sears + */ + +#include +#include +#include + +char * usage = "%s numthreads numops\n"; + +stasis_dirty_page_table_t * dpt; + +unsigned long numops; +unsigned long numthreads; +Page ** p; + +static void* worker(void* arg) { + Page * p = arg; + for(unsigned long i = 0; i < numops; i++) { + stasis_dirty_page_table_set_dirty(dpt, p); + } + return 0; +} + +int main(int argc, char * argv[]) { + if(argc != 3) { printf(usage, argv[0]); abort(); } + char * endptr; + 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]; + + p = malloc(sizeof(Page *) * numthreads); + + Tinit(); + + dpt = stasis_runtime_dirty_page_table(); + + for(int i = 0; i < numthreads; i++) { + p[i] = loadPage(-1, i); + } + + for(int i = 0; i < numthreads; i++) { + pthread_create(&workers[i], 0, worker, p[i]); + } + for(int i = 0; i < numthreads; i++) { + pthread_join(workers[i], 0); + } + + for(int i = 0; i < numthreads; i++) { + releasePage(p[i]); + } + + Tdeinit(); +} + diff --git a/benchmarks/multicore/smallLogEntry.c b/benchmarks/multicore/smallLogEntry.c index 0a92d77..279961e 100644 --- a/benchmarks/multicore/smallLogEntry.c +++ b/benchmarks/multicore/smallLogEntry.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -43,9 +44,11 @@ int main(int argc, char * argv[]) { 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); - + if(stasis_log_type == LOG_TO_FILE) { + l = stasis_log_safe_writes_open(stasis_log_file_name, stasis_log_file_mode, stasis_log_file_permissions, 0); + } else { + l = stasis_log_impl_in_memory_open(); + } for(int i = 0; i < numthreads; i++) { pthread_create(&workers[i], 0, worker, &numops); }