2010-01-21 00:03:17 +00:00
|
|
|
#include <stasis/transactional.h>
|
2007-08-24 23:01:08 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
#include <stasis/bufferManager.h>
|
2009-10-05 22:39:09 +00:00
|
|
|
#include <stasis/bufferManager/legacy/legacyBufferManager.h>
|
2010-08-27 19:43:33 +00:00
|
|
|
#include <stasis/bufferManager/bufferHash.h>
|
|
|
|
#include <stasis/bufferManager/concurrentBufferManager.h>
|
2007-08-24 23:01:08 +00:00
|
|
|
#include <stasis/truncation.h>
|
2009-12-31 19:02:34 +00:00
|
|
|
#include <stasis/logger/logger2.h>
|
2007-08-24 23:01:08 +00:00
|
|
|
/*static stasis_handle_t * memory_factory(lsn_t off, lsn_t len, void * ignored) {
|
|
|
|
stasis_handle_t * h = stasis_handle(open_memory)(off);
|
|
|
|
//h = stasis_handle(open_debug)(h);
|
|
|
|
stasis_write_buffer_t * w = h->append_buffer(h, len);
|
|
|
|
w->h->release_write_buffer(w);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
typedef struct sf_args {
|
|
|
|
char * filename;
|
|
|
|
int openMode;
|
|
|
|
int filePerm;
|
|
|
|
} sf_args;
|
|
|
|
static stasis_handle_t * traditional_file_factory(void * argsP) {
|
|
|
|
sf_args * args = (sf_args*) argsP;
|
|
|
|
stasis_handle_t * h = stasis_handle(open_file)(0, args->filename, args->openMode, args->filePerm);
|
|
|
|
//h = stasis_handle(open_debug)(h);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline long mb_to_page(long mb) {
|
|
|
|
return (mb * 1024 * 1024) / PAGE_SIZE;
|
|
|
|
}
|
|
|
|
|
2009-12-31 19:02:34 +00:00
|
|
|
const char * usage = "./sequentialThroughput [--direct] [--page_count mb] [--stake mb]\n [--deprecatedBM|--deprecatedFH|--log_safe_writes|--log_memory|--nb|--file|--pfile|--nb_pfile|--nb_file]\n";
|
|
|
|
|
2007-08-24 23:01:08 +00:00
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
int direct = 0;
|
|
|
|
int legacyBM = 0;
|
|
|
|
int legacyFH = 0;
|
2009-08-13 05:53:48 +00:00
|
|
|
int stake = 0;
|
2009-12-31 19:02:34 +00:00
|
|
|
int log_mode = 0;
|
2007-08-24 23:01:08 +00:00
|
|
|
long page_count = mb_to_page(100);
|
|
|
|
for(int i = 1; i < argc; i++) {
|
|
|
|
if(!strcmp(argv[i], "--direct")) {
|
|
|
|
direct = 1;
|
|
|
|
bufferManagerO_DIRECT = 1;
|
2009-12-31 19:02:34 +00:00
|
|
|
} else if(!strcmp(argv[i], "--log_safe_writes")) {
|
|
|
|
stasis_log_type = LOG_TO_FILE;
|
|
|
|
log_mode = 1;
|
|
|
|
} else if(!strcmp(argv[i], "--log_memory")) {
|
|
|
|
stasis_log_type = LOG_TO_MEMORY;
|
|
|
|
log_mode = 1;
|
2007-08-24 23:01:08 +00:00
|
|
|
} else if(!strcmp(argv[i], "--deprecatedBM")) {
|
2009-10-05 22:39:09 +00:00
|
|
|
stasis_buffer_manager_factory = stasis_buffer_manager_deprecated_factory;
|
2007-08-24 23:01:08 +00:00
|
|
|
legacyBM = 1;
|
|
|
|
} else if(!strcmp(argv[i], "--deprecatedFH")) {
|
|
|
|
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_DEPRECATED;
|
|
|
|
legacyFH = 1;
|
2007-10-22 20:50:00 +00:00
|
|
|
} else if(!strcmp(argv[i], "--nb")) {
|
|
|
|
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_NON_BLOCKING;
|
|
|
|
legacyBM = 0;
|
|
|
|
legacyFH = 0;
|
|
|
|
} else if(!strcmp(argv[i], "--file")) {
|
|
|
|
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_FILE;
|
|
|
|
legacyBM = 0;
|
|
|
|
legacyFH = 0;
|
2007-08-24 23:01:08 +00:00
|
|
|
} else if(!strcmp(argv[i], "--pfile")) {
|
2007-10-22 20:50:00 +00:00
|
|
|
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_PFILE;
|
|
|
|
legacyBM = 0;
|
|
|
|
legacyFH = 0;
|
|
|
|
} else if(!strcmp(argv[i], "--nb_pfile")) {
|
2007-08-24 23:01:08 +00:00
|
|
|
bufferManagerNonBlockingSlowHandleType = IO_HANDLE_PFILE;
|
2007-10-22 20:50:00 +00:00
|
|
|
} else if(!strcmp(argv[i], "--nb_file")) {
|
2007-08-24 23:01:08 +00:00
|
|
|
bufferManagerNonBlockingSlowHandleType = IO_HANDLE_FILE;
|
|
|
|
} else if(!strcmp(argv[i], "--mb")) {
|
|
|
|
i++;
|
|
|
|
page_count = mb_to_page(atoll(argv[i]));
|
2009-08-13 05:53:48 +00:00
|
|
|
} else if(!strcmp(argv[i], "--stake")) {
|
|
|
|
i++;
|
|
|
|
stake = mb_to_page(atoll(argv[i]));
|
2007-08-24 23:01:08 +00:00
|
|
|
} else {
|
2009-12-31 19:02:34 +00:00
|
|
|
printf("Unknown argument: %s\nUsage: %s\n", argv[i], usage);
|
2007-08-24 23:01:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(legacyFH && direct) {
|
|
|
|
printf("--direct and --deprecatedFH are incompatible with each other\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tinit();
|
|
|
|
|
2009-12-31 19:02:34 +00:00
|
|
|
if(log_mode) {
|
|
|
|
lsn_t prevLSN = -1;
|
|
|
|
byte * arg = calloc(PAGE_SIZE, 1);
|
2009-12-31 23:01:37 +00:00
|
|
|
stasis_log_t * l = stasis_log();
|
|
|
|
|
2009-12-31 19:02:34 +00:00
|
|
|
for(long i = 0; i < page_count; i++) {
|
2010-01-11 20:41:59 +00:00
|
|
|
LogEntry * e = allocUpdateLogEntry(l, prevLSN, -1, OPERATION_NOOP,
|
|
|
|
0, PAGE_SIZE);
|
|
|
|
l->write_entry_done(l, e);
|
2009-12-31 19:02:34 +00:00
|
|
|
}
|
|
|
|
free(arg);
|
|
|
|
} else {
|
|
|
|
if(stake) {
|
|
|
|
Page * p = loadPage(-1, stake);
|
|
|
|
writelock(p->rwlatch,0);
|
|
|
|
stasis_dirty_page_table_set_dirty(stasis_runtime_dirty_page_table(), p);
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
releasePage(p);
|
|
|
|
}
|
2009-08-13 05:53:48 +00:00
|
|
|
|
2009-12-31 19:02:34 +00:00
|
|
|
for(long i =0; i < page_count; i++) {
|
2010-08-27 19:43:33 +00:00
|
|
|
Page * p = loadUninitializedPage(-1, i);
|
2009-12-31 19:02:34 +00:00
|
|
|
writelock(p->rwlatch,0);
|
|
|
|
stasis_dirty_page_table_set_dirty(stasis_runtime_dirty_page_table(), p);
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
releasePage(p);
|
|
|
|
}
|
2007-08-24 23:01:08 +00:00
|
|
|
}
|
|
|
|
Tdeinit();
|
|
|
|
return 0;
|
|
|
|
}
|