Updated some comments.

This commit is contained in:
Sears Russell 2006-06-16 00:27:02 +00:00
parent dc8a3e5d60
commit 209a6916e5
4 changed files with 24 additions and 37 deletions

View file

@ -28,6 +28,8 @@ void TallocInit();
@param size The size of the new record to be allocated. Talloc will allocate a @param size The size of the new record to be allocated. Talloc will allocate a
blob if the record will not easily fit on a page. blob if the record will not easily fit on a page.
@todo need to obtain (transaction-level) write locks _before_ writing log entries. Otherwise, we can deadlock at recovery.
@return the recordid of the new record. @return the recordid of the new record.
*/ */
compensated_function recordid Talloc(int xid, long size); compensated_function recordid Talloc(int xid, long size);

View file

@ -5,6 +5,8 @@
#include <string.h> #include <string.h>
#include <lladd/transactional.h> #include <lladd/transactional.h>
#include <lladd/truncation.h> #include <lladd/truncation.h>
#include <sys/time.h>
#include <time.h>
int main(int argc, char** argv) { int main(int argc, char** argv) {
@ -26,7 +28,8 @@ int main(int argc, char** argv) {
gettimeofday(&start,0); gettimeofday(&start,0);
int count = 0; int count = 0;
while(EOF != (ret=scanf("%as\t%as\n", &key, &value))) { // bleah; gcc would warn without the casts, since it doesn't understand that %as = Allocate String
while(EOF != (ret=scanf("%as\t%as\n", (float*)&key, (float*)&value))) {
if(!ret) { if(!ret) {
printf("Could not parse input!\n"); printf("Could not parse input!\n");
Tabort(xid); Tabort(xid);

View file

@ -152,6 +152,12 @@ void TallocInit() {
compensated_function recordid Talloc(int xid, long size) { compensated_function recordid Talloc(int xid, long size) {
recordid rid; recordid rid;
// @todo How should blobs be handled? Should Talloc do it? If not,
// it's hard for apps to to use it... Similarly, with hints, Talloc
// may need to route certain sizes to certain types of pages (eg;
// small sizes go to fixed page implementations...)
int isBlob = size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT; int isBlob = size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT;
if(isBlob) { if(isBlob) {
@ -161,6 +167,8 @@ compensated_function recordid Talloc(int xid, long size) {
} end_ret(NULLRID); } end_ret(NULLRID);
} else { } else {
Page * p = NULL; Page * p = NULL;
begin_action_ret(pthread_mutex_unlock, &talloc_mutex, NULLRID) { begin_action_ret(pthread_mutex_unlock, &talloc_mutex, NULLRID) {
@ -193,9 +201,8 @@ compensated_function recordid Talloc(int xid, long size) {
slottedPageInitialize(p); slottedPageInitialize(p);
} }
// rid = slottedPreRalloc(xid, size, &p); rid = slottedRawRalloc(p, size); // <--- Important part.
rid = slottedRawRalloc(p, size); Tupdate(xid, rid, NULL, OPERATION_ALLOC); // <--- This hardcodes "slotted" Should we use TallocFromPage() instead?
Tupdate(xid, rid, NULL, OPERATION_ALLOC);
/** @todo does releasePage do the correct error checking? <- Why is this comment here?*/ /** @todo does releasePage do the correct error checking? <- Why is this comment here?*/
releasePage(p); releasePage(p);
} compensate_ret(NULLRID); } compensate_ret(NULLRID);
@ -208,9 +215,13 @@ compensated_function recordid Talloc(int xid, long size) {
compensated_function recordid TallocFromPage(int xid, long page, unsigned long size) { compensated_function recordid TallocFromPage(int xid, long page, unsigned long size) {
recordid rid; recordid rid;
// Does TallocFromPage need to understand blobs? This function
// seems to be too complex; all it does it delegate the allocation
// request to the page type's implementation. (Does it really need
// to check for freespace?)
if(size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT) { if(size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT) {
try_ret(NULLRID) { try_ret(NULLRID) {
rid = preAllocBlobFromPage(xid, page, size); rid = preAllocBlobFromPage(xid, page, size); // <--- ICK!!! Kill this function.
Tupdate(xid,rid, NULL, OPERATION_ALLOC); Tupdate(xid,rid, NULL, OPERATION_ALLOC);
} end_ret(NULLRID); } end_ret(NULLRID);
} else { } else {
@ -226,7 +237,7 @@ compensated_function recordid TallocFromPage(int xid, long page, unsigned long s
} else { } else {
rid = slottedRawRalloc(p, size); rid = slottedRawRalloc(p, size);
assert(rid.size == size); assert(rid.size == size);
Tupdate(xid, rid, NULL, OPERATION_ALLOC); Tupdate(xid, rid, NULL, OPERATION_ALLOC);
} }
releasePage(p); releasePage(p);
} compensate_ret(NULLRID); } compensate_ret(NULLRID);
@ -235,6 +246,8 @@ compensated_function recordid TallocFromPage(int xid, long page, unsigned long s
} }
compensated_function void Tdealloc(int xid, recordid rid) { compensated_function void Tdealloc(int xid, recordid rid) {
// @todo this needs to garbage collect emptry pages / storage regions.
void * preimage = malloc(rid.size); void * preimage = malloc(rid.size);
Page * p; Page * p;
try { try {

View file

@ -183,37 +183,6 @@ size_t slottedFreespace(Page * page) {
} }
/** @todo slottedPreRalloc ignores it's xid parameter; change the
interface? (The xid is there for now, in case it allows some
optimizations later. Perhaps it's better to cluster allocations
from the same xid on the same page, or something...)
@todo slottedPreRalloc should understand deadlock, and try another page if deadlock occurs.
@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) {
recordid ret;
// 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);
ret = slottedRawRalloc(*pp, size);
// assert(ret.size == size);
// 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) { recordid slottedRawRalloc(Page * page, int size) {