2009-03-20 11:36:27 +00:00
|
|
|
#include "lsn_bench_common.h"
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
unlink("storefile.txt");
|
|
|
|
unlink("logfile.txt");
|
|
|
|
char * mode = argv[1];
|
|
|
|
long long num_rids = atoll(argv[2]);
|
|
|
|
long long num_xacts = atoll(argv[3]);
|
|
|
|
long long writes_per_xact = atoll(argv[4]);
|
|
|
|
recordid * rids;
|
|
|
|
recordid * fast;
|
|
|
|
cached_addr * cache;
|
|
|
|
int writeback = !(strcmp(mode, "writeback")&&strcmp(mode,"writeback-net")&&strcmp(mode,"writeback-pipeline"));
|
|
|
|
// stasis_truncation_automatic = 0;
|
|
|
|
|
|
|
|
/*if(!(strcmp(mode, "writeback-pipeline"))) {
|
|
|
|
// pipelining likes big queues
|
2009-05-13 18:04:53 +00:00
|
|
|
// stasis_log_file_write_buffer_size = 50 * 1024 * 1024;
|
2009-03-20 11:36:27 +00:00
|
|
|
} else {
|
|
|
|
}*/
|
2009-05-13 18:04:53 +00:00
|
|
|
stasis_log_file_write_buffer_size = 50 * 1024 * 1024;
|
2009-03-20 11:36:27 +00:00
|
|
|
Tinit();
|
|
|
|
|
|
|
|
alloc_rids(num_rids,&rids,&fast);
|
|
|
|
int net = 0;
|
|
|
|
|
|
|
|
if(writeback) {
|
|
|
|
build_cache(rids,&cache,num_rids);
|
|
|
|
}
|
|
|
|
// XXX move above build_cache!
|
|
|
|
if(!(strcmp(mode, "normal-net")&&strcmp(mode,"writeback-net"))) {
|
|
|
|
net = 1;
|
|
|
|
emulate_remote_pages();
|
|
|
|
emulate_remote_log();
|
|
|
|
}
|
|
|
|
int num_workers = 100;
|
|
|
|
if(!strcmp(mode, "writeback-pipeline")) {
|
|
|
|
emulate_remote_pages();
|
|
|
|
net = 1;
|
|
|
|
num_workers = 10;
|
|
|
|
stasis_log_reordering_usleep_after_flush = net_latency * 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
// stasis_log_reordering_handle_t* handles[num_workers];
|
|
|
|
|
|
|
|
|
|
|
|
lsn_t last_lsn = 0;
|
|
|
|
for(long long x = 0; x < num_xacts; x++) {
|
|
|
|
int xid = Tbegin();
|
|
|
|
if(net && writeback) {
|
|
|
|
writeback_unit_of_work_arg a[num_workers];
|
|
|
|
pthread_t workers[num_workers];
|
|
|
|
for(int i =0 ; i < num_workers; i++) {
|
|
|
|
a[i].num_rids = num_rids;
|
|
|
|
a[i].rid_per_xact = writes_per_xact;
|
|
|
|
a[i].cache = cache;
|
|
|
|
a[i].done = 0;
|
|
|
|
a[i].xid = xid;
|
|
|
|
a[i].workerid = i;
|
|
|
|
a[i].iterationid = x;
|
|
|
|
a[i].divisor = num_workers;
|
|
|
|
pthread_mutex_init(&a[i].mut,0);
|
|
|
|
|
|
|
|
pthread_create(&workers[i], 0, writeback_unit_of_work, &a[i]);
|
|
|
|
}
|
|
|
|
for(int i =0; i < num_workers; i++) {
|
|
|
|
pthread_mutex_lock(&a[i].mut);
|
|
|
|
a[i].done = 1;
|
|
|
|
pthread_mutex_unlock(&a[i].mut);
|
|
|
|
}
|
|
|
|
for(int i =0 ; i < num_workers; i++) {
|
|
|
|
pthread_join(workers[i],0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* if(writeback && net) {
|
|
|
|
for(int i = 0; i < num_workers; i++) {
|
|
|
|
handles[i] = stasis_log_reordering_handle_open(
|
2009-04-13 22:50:12 +00:00
|
|
|
&stasis_transaction_table[xid%MAX_TRANSACTIONS],
|
2009-03-20 11:36:27 +00:00
|
|
|
stasis_log_file,
|
2009-05-13 18:04:53 +00:00
|
|
|
(0.9*stasis_log_file_write_buffer_size)/num_workers,
|
2009-03-20 11:36:27 +00:00
|
|
|
//512*1024/ua->divisor, // 0.5 mb in log tail at once
|
|
|
|
1000000/num_workers, // max num outstanding requests
|
|
|
|
(50 * 1024 * 1024)/num_workers // max backlog in bytes
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
|
|
|
for(long long j = 0; j < writes_per_xact; j++) {
|
|
|
|
// long long idx = ((x*writes_per_xact)+j)%num_rids;
|
|
|
|
long long idx = j % num_rids;
|
|
|
|
// if(!(j % 100)) { printf("."); fflush(stdout); }
|
|
|
|
if(!(strcmp(mode, "normal")&&strcmp(mode, "normal-net"))) {
|
|
|
|
TsetLsnFree(xid, rids[idx], &j);
|
|
|
|
} else {
|
|
|
|
assert(writeback);
|
|
|
|
int old = cache[idx].val;
|
|
|
|
cache[idx].val = j;
|
|
|
|
if(net) {
|
|
|
|
/* TsetReorderableWriteBack(xid, handles[j%num_workers], cache[idx].pid,
|
|
|
|
cache[idx].off, cache[idx].len,&j,&old);
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
last_lsn = TsetWriteBack(xid, cache[idx].pid,cache[idx].off,
|
|
|
|
cache[idx].len,&j,&old);
|
|
|
|
assert(last_lsn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if(writeback && net) {
|
|
|
|
for(int j = 0; j < num_workers; j++) {
|
|
|
|
stasis_log_reordering_handle_close(handles[j]);
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
}
|
|
|
|
if(net) {
|
2009-04-13 22:50:12 +00:00
|
|
|
last_lsn = stasis_transaction_table[xid%MAX_TRANSACTIONS].prevLSN;
|
2009-03-20 11:36:27 +00:00
|
|
|
}
|
|
|
|
Tcommit(xid);
|
|
|
|
}
|
|
|
|
// XXX hack; really, want to register upcall in buffermanager...
|
|
|
|
if(writeback) {
|
|
|
|
printf("starting writeback"); fflush(stdout);
|
|
|
|
assert(last_lsn);
|
|
|
|
for(long long i = 0; i < num_rids; i++) {
|
|
|
|
Page *p = loadPage(-1, rids[i].page);
|
|
|
|
writelock(p->rwlatch,0);
|
2009-06-02 18:25:35 +00:00
|
|
|
stasis_record_write(-1, p, rids[i], (byte*)&cache[i].val);
|
|
|
|
stasis_page_lsn_write(-1, p, last_lsn);
|
2009-03-20 11:36:27 +00:00
|
|
|
unlock(p->rwlatch);
|
|
|
|
releasePage(p);
|
|
|
|
releasePage(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Tdeinit();
|
|
|
|
}
|