Eliminated slottedPreRalloc

This commit is contained in:
Sears Russell 2006-06-16 00:05:44 +00:00
parent ffac2d6362
commit dc8a3e5d60
5 changed files with 52 additions and 46 deletions

View file

@ -193,7 +193,8 @@ compensated_function recordid Talloc(int xid, long size) {
slottedPageInitialize(p);
}
rid = slottedPreRalloc(xid, size, &p);
// rid = slottedPreRalloc(xid, size, &p);
rid = slottedRawRalloc(p, size);
Tupdate(xid, rid, NULL, OPERATION_ALLOC);
/** @todo does releasePage do the correct error checking? <- Why is this comment here?*/
releasePage(p);

View file

@ -2,7 +2,7 @@
#include "../page.h"
#include "../blobManager.h" /** So that we can call sizeof(blob_record_t) */
//#include "../blobManager.h" /** So that we can call sizeof(blob_record_t) */
#include "slotted.h"
#include <assert.h>
@ -192,32 +192,41 @@ 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, unsigned long size, Page ** pp) {
/*compensated_function recordid slottedPreRalloc(int xid, unsigned 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);
// int isBlob = 0;
//if(size == BLOB_SLOT) {
// isBlob = 1;
// size = sizeof(blob_record_t);
// }
// assert(size < BLOB_THRESHOLD_SIZE);
assert(*page_type_ptr(*pp) == SLOTTED_PAGE);
// assert(*page_type_ptr(*pp) == SLOTTED_PAGE);
ret = slottedRawRalloc(*pp, size);
assert(ret.size == size);
// assert(ret.size == size);
if(isBlob) {
*slot_length_ptr(*pp, ret.slot) = BLOB_SLOT;
}
// if(isBlob) {
// *slot_length_ptr(*pp, ret.slot) = BLOB_SLOT;
// }
DEBUG("alloced rid = {%d, %d, %ld}\n", ret.page, ret.slot, ret.size);
return ret;
}
}*/
recordid slottedRawRalloc(Page * page, int size) {
int type = size;
if(type >= SLOT_TYPE_BASE) {
assert(type < SLOT_TYPE_END);
size = SLOT_TYPE_LENGTHS[type-SLOT_TYPE_BASE];
}
assert(type != INVALID_SLOT);
assert(size < SLOT_TYPE_BASE && size >= 0);
writelock(page->rwlatch, 342);
assert(*page_type_ptr(page) == SLOTTED_PAGE);
recordid rid;
@ -235,13 +244,16 @@ recordid slottedRawRalloc(Page * page, int size) {
really_do_ralloc(page, rid);
assert(size == *slot_length_ptr(page, rid.slot));
*slot_length_ptr(page, rid.slot) = type;
/* DEBUG("slot: %d freespace: %d\n", rid.slot, freeSpace); */
assert(slottedFreespaceUnlocked(page) >= 0);
writeunlock(page->rwlatch);
return rid;
}

View file

@ -96,7 +96,7 @@ void slottedPageInitialize(Page * p);
* @see postRallocSlot the implementation of the second phase.
*
*/
compensated_function recordid slottedPreRalloc(int xid, unsigned long size, Page**p);
//compensated_function recordid slottedPreRalloc(int xid, unsigned long size, Page**p);
/**
* The second phase of slot allocation. Called after the log entry

View file

@ -87,15 +87,7 @@ void * workerThreadWriting(void * q) {
int offset = *(int*)q;
recordid rids[RECORDS_PER_THREAD];
for(int i = 0 ; i < RECORDS_PER_THREAD; i++) {
/* Page * tmp;
pthread_mutex_lock(&ralloc_mutex);
rids[i] = slottedPreRalloc(1, sizeof(int), &tmp);
slottedPostRalloc(-1, tmp, 1, rids[i]);
tmp->LSN = 0;
*lsn_ptr(tmp) = 0;
releasePage(tmp);
pthread_mutex_unlock(&ralloc_mutex);
*/
rids[i] = Talloc(-1, sizeof(int));
/* printf("\nRID:\t%d,%d\n", rids[i].page, rids[i].slot); */
/* fflush(NULL); */

View file

@ -76,7 +76,8 @@ START_TEST(operation_physical_do_undo) {
xid = -1;
Page * p = loadPage(xid, TpageAlloc(xid));
slottedPageInitialize(p);
rid = slottedPreRalloc(xid, sizeof(int), &p);
// rid = slottedPreRalloc(xid, sizeof(int), &p);
rid = slottedRawRalloc(p, sizeof(int));
releasePage(p);
//rid = Talloc(xid, sizeof(int));
buf = 1;