From a11fbdd9e681b2a58c963a4e0b9f648a508058e2 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Tue, 13 Jun 2006 20:00:46 +0000 Subject: [PATCH] Did away with slottedPreRallocFromPage. --- lladd/truncation.h | 5 +++++ src/lladd/operations/alloc.c | 35 ++++++++++------------------------- src/lladd/page/slotted.c | 34 ++-------------------------------- src/lladd/page/slotted.h | 5 ----- src/lladd/truncation.c | 1 - 5 files changed, 17 insertions(+), 63 deletions(-) diff --git a/lladd/truncation.h b/lladd/truncation.h index 2e938b6..1f99a70 100644 --- a/lladd/truncation.h +++ b/lladd/truncation.h @@ -44,6 +44,11 @@ terms specified in this license. * * Implementation of log truncation for lladd. * + * @todo TRUNCATE_INTERVAL should be dynamically set... + * @todo log truncation policy should be set of the percentage of the log that can be truncated + * (instead of by absolute logfile size) + * @todo avoid copying the non-truncated tail of the log each time truncation occurs. + * * $Id$ * */ diff --git a/src/lladd/operations/alloc.c b/src/lladd/operations/alloc.c index f5a0d57..af1d961 100644 --- a/src/lladd/operations/alloc.c +++ b/src/lladd/operations/alloc.c @@ -77,13 +77,6 @@ */ //}end static int operate(int xid, Page * p, lsn_t lsn, recordid rid, const void * dat) { - /* * @ todo Currently, T alloc () needs to clean up the page type (for recovery). Should this be elsewhere? */ - - /* if(*page_type_ptr(p) == UNINITIALIZED_PAGE) { - *page_type_ptr(p) = SLOTTED_PAGE; - } - - assert(*page_type_ptr(p) == SLOTTED_PAGE); */ if(rid.size >= BLOB_THRESHOLD_SIZE && rid.size != BLOB_SLOT) { allocBlob(xid, p, lsn, rid); @@ -203,7 +196,6 @@ compensated_function recordid Talloc(int xid, long size) { compensated_function recordid TallocFromPage(int xid, long page, long size) { recordid rid; - Page * p = NULL; if(size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT) { try_ret(NULLRID) { rid = preAllocBlobFromPage(xid, page, size); @@ -211,29 +203,22 @@ compensated_function recordid TallocFromPage(int xid, long page, long size) { } end_ret(NULLRID); } else { begin_action_ret(pthread_mutex_unlock, &talloc_mutex, NULLRID) { + Page * p = loadPage(xid, page); pthread_mutex_lock(&talloc_mutex); - rid = slottedPreRallocFromPage(xid, page, size, &p); - if(rid.size == size) { - Tupdate(xid,rid, NULL, OPERATION_ALLOC); - } else { - p = loadPage(xid, page); + + if(slottedFreespace(p) < size) { slottedCompact(p); - releasePage(p); - p = NULL; - rid = slottedPreRallocFromPage(xid, page, size, &p); - if(rid.size == size) { - Tupdate(xid,rid, NULL, OPERATION_ALLOC); - } else { - assert(rid.size < 0); - } } - if(p) { - /* @todo alloc.c pins multiple pages -> Will deadlock with small buffer sizes.. */ - releasePage(p); + if(slottedFreespace(p) < size) { + rid = NULLRID; + } else { + rid = slottedRawRalloc(p, size); + assert(rid.size == size); + Tupdate(xid, rid, NULL, OPERATION_ALLOC); } + releasePage(p); } compensate_ret(NULLRID); } - return rid; } diff --git a/src/lladd/page/slotted.c b/src/lladd/page/slotted.c index 7ba7765..d0d2d8c 100644 --- a/src/lladd/page/slotted.c +++ b/src/lladd/page/slotted.c @@ -196,16 +196,12 @@ size_t slottedFreespace(Page * page) { @todo need to obtain (transaction-level) write locks _before_ writing log entries. Otherwise, we can deadlock at recovery. */ compensated_function recordid slottedPreRalloc(int xid, long size, Page ** pp) { - recordid ret; - int isBlob = 0; - if(size == BLOB_SLOT) { isBlob = 1; size = sizeof(blob_record_t); } - assert(size < BLOB_THRESHOLD_SIZE); @@ -237,8 +233,9 @@ compensated_function recordid slottedPreRalloc(int xid, long size, Page ** pp) { } end_ret(NULLRID); slottedPageInitialize(*pp); } - + assert(*page_type_ptr(*pp) == SLOTTED_PAGE); ret = slottedRawRalloc(*pp, size); + assert(ret.size == size); if(isBlob) { *slot_length_ptr(*pp, ret.slot) = BLOB_SLOT; @@ -249,33 +246,6 @@ compensated_function recordid slottedPreRalloc(int xid, long size, Page ** pp) { return ret; } -compensated_function recordid slottedPreRallocFromPage(int xid, long page, long size, Page **pp) { - int isBlob = 0; - if(size == BLOB_SLOT) { - isBlob = 1; - size = sizeof(blob_record_t); - } - try_ret(NULLRID) { - *pp = loadPage(xid, page); - } end_ret(NULLRID); - if(slottedFreespace(*pp) < size) { - releasePage(*pp); - *pp = NULL; - return NULLRID; - } - - if(*page_type_ptr(*pp) == UNINITIALIZED_PAGE) { - slottedPageInitialize(*pp); - } - assert(*page_type_ptr(*pp) == SLOTTED_PAGE); - recordid ret = slottedRawRalloc(*pp, size); - assert(ret.size == size); - if(isBlob) { - *slot_length_ptr(*pp, ret.slot) = BLOB_SLOT; - } - return ret; - -} recordid slottedRawRalloc(Page * page, int size) { diff --git a/src/lladd/page/slotted.h b/src/lladd/page/slotted.h index bb5fa37..938b4c0 100644 --- a/src/lladd/page/slotted.h +++ b/src/lladd/page/slotted.h @@ -92,11 +92,6 @@ void slottedPageInitialize(Page * p); * */ compensated_function recordid slottedPreRalloc(int xid, long size, Page**p); -/** - Identical to slottedPreRalloc, but allows the user to specify which page the - record should be allocated in. - */ -compensated_function recordid slottedPreRallocFromPage(int xid, long page, long size, Page**p); /** * The second phase of slot allocation. Called after the log entry diff --git a/src/lladd/truncation.c b/src/lladd/truncation.c index 3c0af38..7c7a746 100644 --- a/src/lladd/truncation.c +++ b/src/lladd/truncation.c @@ -132,7 +132,6 @@ static void* periodicTruncation(void * ignored) { if(LogFlushedLSN() - LogTruncationPoint() > TARGET_LOG_SIZE) { truncateNow(); } - // @todo TRUNCATE_INTERVAL should be dynamically set... struct timeval now; struct timespec timeout; int timeret = gettimeofday(&now, 0);