From a6aa8ed9420a2543245886be916e1e9a48f84f18 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Wed, 5 Aug 2009 20:02:33 +0000 Subject: [PATCH] added method to access dirtyPageTable --- benchmarks/sequentialThroughput.c | 3 +-- src/stasis/operations/lsmTree.c | 2 +- src/stasis/operations/regions.c | 8 ++++++++ src/stasis/page/raw.c | 2 +- src/stasis/transactional2.c | 6 ++++-- stasis/operations/lsmTable.h | 5 +++-- stasis/transactional.h | 4 ++++ stasis/truncation.h | 4 ---- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/benchmarks/sequentialThroughput.c b/benchmarks/sequentialThroughput.c index c608515..7a98e03 100644 --- a/benchmarks/sequentialThroughput.c +++ b/benchmarks/sequentialThroughput.c @@ -80,11 +80,10 @@ int main(int argc, char ** argv) { for(long i =0; i < page_count; i++) { Page * p = loadPage(-1, i); - stasis_dirty_page_table_set_dirty(stasis_dirty_page_table, p); + stasis_dirty_page_table_set_dirty(stasis_runtime_dirty_page_table(), p); releasePage(p); } - Tdeinit(); return 0; } diff --git a/src/stasis/operations/lsmTree.c b/src/stasis/operations/lsmTree.c index 423d661..2dce592 100644 --- a/src/stasis/operations/lsmTree.c +++ b/src/stasis/operations/lsmTree.c @@ -56,7 +56,7 @@ void TlsmRegionForceRid(int xid, void *conf) { a.regionList.slot = i; pageid_t pid; Tread(xid,a.regionList,&pid); - stasis_dirty_page_table_flush_range(stasis_dirty_page_table, pid, pid+a.regionSize); + stasis_dirty_page_table_flush_range(stasis_runtime_dirty_page_table(), pid, pid+a.regionSize); // TregionDealloc(xid,pid); } } diff --git a/src/stasis/operations/regions.c b/src/stasis/operations/regions.c index 11a90b2..91495bb 100644 --- a/src/stasis/operations/regions.c +++ b/src/stasis/operations/regions.c @@ -273,6 +273,14 @@ static void TregionAllocHelper(int xid, pageid_t page, pageid_t pageCount, int a new_tag.size = PAGEID_T_MAX; + // We're extending the page file, so pre-fill the stasis buffer manager with dirty zeros. This + // prevents the file from becoming sparse. + for(pageid_t i = page+1; i < newPageid; i++) { + Page * p = loadUninitializedPage(xid, i); + stasis_dirty_page_table_set_dirty(stasis_runtime_dirty_page_table(), p); + releasePage(p); + } + } new_tag.prev_size = pageCount; // Create the new region, and disassociate it from this transaction immediately. diff --git a/src/stasis/page/raw.c b/src/stasis/page/raw.c index 561dea6..f8c66eb 100644 --- a/src/stasis/page/raw.c +++ b/src/stasis/page/raw.c @@ -25,7 +25,7 @@ void rawPageSetData(int xid, lsn_t lsn, Page * p) { // writelock(p->rwlatch, 255); rawPageWriteLSN(xid, p, lsn); // XXX should be handled in releasePage. - stasis_dirty_page_table_set_dirty(stasis_dirty_page_table, p); + stasis_dirty_page_table_set_dirty(stasis_runtime_dirty_page_table(), p); // unlock(p->rwlatch); return; } diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index ca1eba9..eb7d81e 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -29,7 +29,6 @@ static int stasis_transaction_table_num_active = 0; static int stasis_transaction_table_xid_count = 0; static stasis_log_t* stasis_log_file = 0; -// XXX should be static! stasis_dirty_page_table_t * stasis_dirty_page_table = 0; static stasis_truncation_t * stasis_truncation = 0; /** @@ -51,6 +50,10 @@ void stasis_transaction_table_init() { } } +void * stasis_runtime_dirty_page_table() { + return stasis_dirty_page_table; +} + int Tinit() { pthread_mutex_init(&stasis_transaction_table_mutex, NULL); stasis_initted = 1; @@ -60,7 +63,6 @@ int Tinit() { stasis_transaction_table_init(); stasis_operation_table_init(); - stasis_dirty_page_table_init(); stasis_log_file = 0; diff --git a/stasis/operations/lsmTable.h b/stasis/operations/lsmTable.h index 0bcfbb5..03d3e16 100644 --- a/stasis/operations/lsmTable.h +++ b/stasis/operations/lsmTable.h @@ -10,6 +10,7 @@ #include #include "lsmIterators.h" #include +#include namespace rose { @@ -93,7 +94,7 @@ namespace rose { rose::slot_index_t ret = mc->append(xid, *i); if(ret == rose::NOSPACE) { - stasis_dirty_page_table_set_dirty(stasis_dirty_page_table, p); + stasis_dirty_page_table_set_dirty((stasis_dirty_page_table_t*)stasis_runtime_dirty_page_table(), p); mc->pack(); unlock(p->rwlatch); releasePage(p); @@ -108,7 +109,7 @@ namespace rose { } (*inserted)++; } - stasis_dirty_page_table_set_dirty(stasis_dirty_page_table, p); + stasis_dirty_page_table_set_dirty((stasis_dirty_page_table_t*)stasis_runtime_dirty_page_table(), p); mc->pack(); unlock(p->rwlatch); releasePage(p); diff --git a/stasis/transactional.h b/stasis/transactional.h index 462e98c..1f0131f 100644 --- a/stasis/transactional.h +++ b/stasis/transactional.h @@ -794,6 +794,10 @@ void TtruncateLog(); * that stasis_log_file is no longer global. */ void * stasis_log(void); +/** + * XXX if releasePage kept the dirty page table up to date, it would greatly reduce the number of places where the dirty page table is updated. + */ +void * stasis_runtime_dirty_page_table(); #include "operations.h" diff --git a/stasis/truncation.h b/stasis/truncation.h index b93dd90..e33762d 100644 --- a/stasis/truncation.h +++ b/stasis/truncation.h @@ -76,9 +76,5 @@ void stasis_truncation_thread_start(stasis_truncation_t* trunc); Initiate a round of log truncation. */ int stasis_truncation_truncate(stasis_truncation_t* trunc, int force); -/** - * XXX if releasePage kept the dirty page table up to date, it would greatly reduce the number of places where the dirty page table is updated. - */ -extern stasis_dirty_page_table_t * stasis_dirty_page_table; END_C_DECLS #endif