Skip to content

Commit

Permalink
Fix the nestloopindexexecutor to work with anti-cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
linmagit committed Mar 23, 2016
1 parent 4f40b45 commit 4fb3757
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 16 deletions.
2 changes: 1 addition & 1 deletion buildtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, args):
self.ANTICACHE_NVM = False
self.ANTICACHE_DRAM = False
self.ARIES= False
self.ANTICACHE_COUNTER = False
self.ANTICACHE_COUNTER = True
self.ANTICACHE_TIMESTAMPS = True
self.ANTICACHE_TIMESTAMPS_PRIME = True

Expand Down
7 changes: 4 additions & 3 deletions src/ee/anticache/AntiCacheEvictionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
#include <time.h>
#include <stdlib.h>
// FIXME: This is relatively small. 2500 might be a better guess
#define MAX_EVICTED_TUPLE_SIZE 1060
#define MAX_EVICTED_TUPLE_SIZE 100
//#define MAX_EVICTED_TUPLE_SIZE 1060
//#define MAX_EVICTED_TUPLE_SIZE 2500

namespace voltdb
Expand Down Expand Up @@ -2097,14 +2098,14 @@ bool AntiCacheEvictionManager::blockingMerge() {
// copy the block ids into an array
int num_blocks = 0;
for(vector<int32_t>::iterator itr = m_evicted_block_ids_sync.begin(); itr != m_evicted_block_ids_sync.end(); ++itr) {
VOLT_TRACE("Marking block 0x%x as being needed for uneviction", *itr);
VOLT_DEBUG("Marking block 0x%x as being needed for uneviction", *itr);
block_ids[num_blocks++] = *itr;
}

// copy the tuple offsets into an array
int num_tuples = 0;
for(vector<int32_t>::iterator itr = m_evicted_offsets_sync.begin(); itr != m_evicted_offsets_sync.end(); ++itr) {
VOLT_TRACE("Marking tuple %d from %s as being needed for uneviction", *itr, m_evicted_tables_sync[num_tuples]->name().c_str());
VOLT_DEBUG("Marking tuple %d from %s as being needed for uneviction", *itr, m_evicted_tables_sync[num_tuples]->name().c_str());
tuple_ids[num_tuples++] = *itr;
}
// HACK
Expand Down
6 changes: 3 additions & 3 deletions src/ee/anticache/AntiCacheEvictionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
#define ANTICACHE_MERGE_BUFFER_SIZE 100000

#ifdef ANTICACHE_COUNTER
#define SKETCH_WIDTH 32768
#define SKETCH_MASK 32767
#define SKETCH_WIDTH 262144
#define SKETCH_MASK 262143
//#define SKETCH_WIDTH 16384
//#define SKETCH_MASK 16383
//#define SKETCH_WIDTH 1048576
//#define SKETCH_MASK 1048575
#define SKETCH_HEIGHT 3
#define SKETCH_THRESH 200
#define SKETCH_THRESH 10
#define SKETCH_SAMPLE_SIZE 200
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ee/common/MMAPMemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

pthread_mutex_t MMAPMemoryManager::m_mutex = PTHREAD_MUTEX_INITIALIZER;

const unsigned int DEFAULT_MMAP_SIZE = 256 * 1024 * 1024;
const unsigned int DEFAULT_MMAP_SIZE = 2047 * 1024 * 1024;

MMAPMemoryManager::MMAPMemoryManager()
: m_size(DEFAULT_MMAP_SIZE), m_allocated(0),
Expand Down
2 changes: 1 addition & 1 deletion src/ee/execution/VoltDBEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ int VoltDBEngine::executeQuery(int64_t planfragmentId,
for (int ctr = 0; ctr < ttl; ++ctr) {
AbstractExecutor *executor = execsForFrag->list[ctr];
PlanNodeType nodeType = executor->getPlanNode()->getPlanNodeType();
//printf("nodeType: %d\n", nodeType);
VOLT_TRACE("nodeType: %d\n", nodeType);
if (nodeType == PLAN_NODE_TYPE_UPDATE || nodeType == PLAN_NODE_TYPE_DELETE)
m_executorContext->getAntiCacheEvictionManager()->m_update_access =
true;
Expand Down
50 changes: 46 additions & 4 deletions src/ee/executors/nestloopindexexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
#ifdef ANTICACHE
AntiCacheEvictionManager* eviction_manager = executor_context->getAntiCacheEvictionManager();
bool hasEvictedTable = (eviction_manager != NULL && inner_table->getEvictedTable() != NULL);
bool blockingMergeSuccessful = false;
#endif

//
Expand Down Expand Up @@ -284,7 +285,7 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
setNValue(ctr,
inline_node->getSearchKeyExpressions()[ctr]->eval(&outer_tuple, NULL));
}
VOLT_TRACE("Searching %s", index_values.debug("").c_str());
VOLT_TRACE("Searching %s, isEvicted: %d", index_values.debug("").c_str(), outer_tuple.isEvicted());

//
// In order to apply the Expression trees in our join, we need
Expand Down Expand Up @@ -326,14 +327,20 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
(m_lookupType != INDEX_LOOKUP_TYPE_EQ &&
!(inner_tuple = index->nextValue()).isNullTuple()))
{
VOLT_TRACE("Searching inner!");
match = true;
inner_table->updateTupleAccessCount();

// Anti-Cache Evicted Tuple Tracking
#ifdef ANTICACHE
#ifdef ANTICACHE_COUNTER
inner_tuple.setTempMergedFalse();
#endif
blockingMergeSuccessful = false;
// We are pointing to an entry for an evicted tuple
VOLT_TRACE("If condition before check: %d %d!", hasEvictedTable, inner_tuple.isEvicted());
if (hasEvictedTable && inner_tuple.isEvicted()) {
VOLT_INFO("Tuple in NestLoopIndexScan is evicted %s", inner_catalogTable->name().c_str());
VOLT_TRACE("Tuple in NestLoopIndexScan is evicted %s", inner_catalogTable->name().c_str());

// Tell the EvictionManager's internal tracker that we touched this mofo
eviction_manager->recordEvictedAccess(inner_catalogTable, &inner_tuple);
Expand All @@ -347,13 +354,42 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
// TODO: possibly an alternate codepath that simply looks through all the tuples
// for evicted tuples and then see if we have any non-blockable accesses
if (eviction_manager->hasBlockableEvictedAccesses()) {
//VOLT_ERROR("From nestloop!");
eviction_manager->blockingMerge();
//VOLT_ERROR("From sync!");
#ifdef ANTICACHE_COUNTER
if (eviction_manager->m_update_access)
#endif
blockingMergeSuccessful = eviction_manager->blockingMerge();
} else {
//VOLT_ERROR("From abrt!");
blockingMergeSuccessful = false;
//eviction_manager->blockingMerge();
continue;
}
}

if (blockingMergeSuccessful) {
//printf("Scan from merge.\n");
VOLT_TRACE("grabbing tuple again");
if (m_lookupType == INDEX_LOOKUP_TYPE_EQ) {
index->moveToKey(&index_values);
inner_tuple = index->nextValueAtKey();
} else {
if (m_lookupType == INDEX_LOOKUP_TYPE_GT)
index->moveToGreaterThanKey(&index_values);
else
index->moveToKeyOrGreater(&index_values);
inner_tuple = index->nextValue();
}

#ifdef ANTICACHE_COUNTER
inner_tuple.setTempMergedFalse();
#endif

if (inner_tuple.isNullTuple()) {
VOLT_INFO("We've got a null tuple for some reason");
}
VOLT_TRACE("Merged Tuple: %s", m_tuple.debug(m_targetTable->name()).c_str());
}
#endif

VOLT_TRACE("inner_tuple:%s",
Expand Down Expand Up @@ -395,6 +431,12 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
}
#endif
}
#if defined(ANTICACHE) && defined(ANTICACHE_COUNTER)
if (inner_tuple.isTempMerged()) {
//printf("isTempMerged?\n");
delete[] inner_tuple.address();
}
#endif
} // WHILE

//
Expand Down
7 changes: 4 additions & 3 deletions src/frontend/edu/brown/hstore/conf/HStoreConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,10 @@ public final class SiteConf extends Conf {
description="Reserved eviction time for anti-caching after warmup of the benchmark. This requires that the system "+
"is compiled with ${site.anticache_warmup_eviction_enable} "+
"set to true.",
defaultInt = 480000,
//defaultInt = 0000,
//defaultInt = 30000,
//defaultInt = 300000,
//defaultInt = 900000,
defaultInt = 0000,
//defaultInt = 150000,
experimental=true
)
public int anticache_warmup_eviction_time;
Expand Down

0 comments on commit 4fb3757

Please sign in to comment.