new benchmarks revealed that inserts for linkedList, pageOrientedList were taking O(n) time, yielding O(n^2)
time to build a list, since the lists could not contain duplicate keys. These operations are now O(1), and the lists can contain duplicates.
This commit is contained in:
parent
f28df29736
commit
18c772234d
6 changed files with 104 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
LDADD=$(top_builddir)/src/2pc/lib2pc.a $(top_builddir)/src/libdfa/libdfa.a \
|
||||
$(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a \
|
||||
$(top_builddir)/src/libdfa/librw.a
|
||||
bin_PROGRAMS=naiveHash logicalHash readLogicalHash naiveMultiThreaded logicalMultThreaded rawSet arrayListSet logicalMultiReaders
|
||||
bin_PROGRAMS=naiveHash logicalHash readLogicalHash naiveMultiThreaded logicalMultThreaded rawSet arrayListSet logicalMultiReaders linearHashNTA linkedListNTA
|
||||
AM_CFLAGS= -g -Wall -pedantic -std=gnu99
|
||||
|
||||
SUBDIRS=berkeleyDB
|
||||
|
|
46
benchmarks/linearHashNTA.c
Normal file
46
benchmarks/linearHashNTA.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <lladd/transactional.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
assert(argc == 3);
|
||||
|
||||
int xact_count = atoi(argv[1]);
|
||||
int count = atoi(argv[2]);
|
||||
int k;
|
||||
|
||||
/* unlink("storefile.txt");
|
||||
unlink("logfile.txt");
|
||||
unlink("blob0_file.txt");
|
||||
unlink("blob1_file.txt"); */
|
||||
|
||||
Tinit();
|
||||
int xid = Tbegin();
|
||||
|
||||
recordid hash = ThashCreate(xid, sizeof(int), sizeof(int));
|
||||
|
||||
Tcommit(xid);
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(k = 0; k < xact_count; k++) {
|
||||
|
||||
xid = Tbegin();
|
||||
|
||||
for(;i < count *(k+1) ; i++) {
|
||||
|
||||
ThashInsert(xid, hash, (byte*)&i, sizeof(int), (byte*)&i, sizeof(int));
|
||||
|
||||
}
|
||||
|
||||
Tcommit(xid);
|
||||
|
||||
}
|
||||
|
||||
Tdeinit();
|
||||
|
||||
}
|
46
benchmarks/linkedListNTA.c
Normal file
46
benchmarks/linkedListNTA.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <lladd/transactional.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
assert(argc == 3);
|
||||
|
||||
int xact_count = atoi(argv[1]);
|
||||
int count = atoi(argv[2]);
|
||||
int k;
|
||||
|
||||
/* unlink("storefile.txt");
|
||||
unlink("logfile.txt");
|
||||
unlink("blob0_file.txt");
|
||||
unlink("blob1_file.txt"); */
|
||||
|
||||
Tinit();
|
||||
int xid = Tbegin();
|
||||
|
||||
recordid hash = TlinkedListCreate(xid, sizeof(int), sizeof(int));
|
||||
|
||||
Tcommit(xid);
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(k = 0; k < xact_count; k++) {
|
||||
|
||||
xid = Tbegin();
|
||||
|
||||
for(;i < count *(k+1) ; i++) {
|
||||
|
||||
TlinkedListInsert(xid, hash, (byte*)&i, sizeof(int), (byte*)&i, sizeof(int));
|
||||
|
||||
}
|
||||
|
||||
Tcommit(xid);
|
||||
|
||||
}
|
||||
|
||||
Tdeinit();
|
||||
|
||||
}
|
|
@ -223,7 +223,8 @@ compensated_function static int __ThashInsert(int xid, recordid hashHeader, cons
|
|||
|
||||
// int before = TpagedListSpansPages(xid, bucketList);
|
||||
|
||||
ret = TpagedListInsert(xid, bucketList, key, keySize, value, valueSize);
|
||||
ret = TpagedListRemove(xid, bucketList, key, keySize);
|
||||
TpagedListInsert(xid, bucketList, key, keySize, value, valueSize);
|
||||
|
||||
// int after = TpagedListSpansPages(xid, bucketList);
|
||||
// if(before != after) { // Page overflowed...
|
||||
|
@ -233,7 +234,8 @@ compensated_function static int __ThashInsert(int xid, recordid hashHeader, cons
|
|||
|
||||
} else {
|
||||
assert(lhh.keySize == keySize); assert(lhh.valueSize == valueSize);
|
||||
ret = TlinkedListInsert(xid, bucket, key, keySize, value, valueSize);
|
||||
ret = TlinkedListRemove(xid, bucket, key, keySize);
|
||||
TlinkedListInsert(xid, bucket, key, keySize, value, valueSize);
|
||||
}
|
||||
if(ret) { lhh.numEntries--; }
|
||||
Tset(xid, hashHeader, &lhh);
|
||||
|
|
|
@ -106,10 +106,10 @@ compensated_function static int operateRemove(int xid, Page *p, lsn_t lsn, reco
|
|||
}
|
||||
|
||||
compensated_function int TlinkedListInsert(int xid, recordid list, const byte * key, int keySize, const byte * value, int valueSize) {
|
||||
int ret;
|
||||
try_ret(compensation_error()) {
|
||||
int ret = 0;
|
||||
/* try_ret(compensation_error()) {
|
||||
ret = TlinkedListRemove(xid, list, key, keySize);
|
||||
} end_ret(compensation_error());
|
||||
} end_ret(compensation_error()); */
|
||||
|
||||
lladd_linkedListInsert_log * undoLog = malloc(sizeof(lladd_linkedListInsert_log) + keySize);
|
||||
|
||||
|
|
|
@ -29,12 +29,13 @@ compensated_function int TpagedListInsert(int xid, recordid list, const byte * k
|
|||
Tread(xid, list, &header);
|
||||
recordid headerRid = list;
|
||||
|
||||
byte * garbage;
|
||||
ret = (TpagedListFind(xid, list, key, keySize, &garbage) != -1);
|
||||
/* byte * garbage;
|
||||
ret = (TpagedListFind(xid, list, key, keySize, &garbage) != -1);
|
||||
if(ret) {
|
||||
free(garbage);
|
||||
TpagedListRemove(xid, list, key, keySize);
|
||||
}
|
||||
} */
|
||||
ret = 0;
|
||||
int entrySize = sizeof(pagedListEntry) + keySize + valueSize;
|
||||
|
||||
recordid rid = TallocFromPage(xid, headerRid.page, entrySize);
|
||||
|
|
Loading…
Reference in a new issue