Skip to content
This repository was archived by the owner on Aug 10, 2025. It is now read-only.

Commit 4fb3757

Browse files
committed
Fix the nestloopindexexecutor to work with anti-cache.
1 parent 4f40b45 commit 4fb3757

File tree

7 files changed

+60
-16
lines changed

7 files changed

+60
-16
lines changed

buildtools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, args):
4646
self.ANTICACHE_NVM = False
4747
self.ANTICACHE_DRAM = False
4848
self.ARIES= False
49-
self.ANTICACHE_COUNTER = False
49+
self.ANTICACHE_COUNTER = True
5050
self.ANTICACHE_TIMESTAMPS = True
5151
self.ANTICACHE_TIMESTAMPS_PRIME = True
5252

src/ee/anticache/AntiCacheEvictionManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
#include <time.h>
4848
#include <stdlib.h>
4949
// FIXME: This is relatively small. 2500 might be a better guess
50-
#define MAX_EVICTED_TUPLE_SIZE 1060
50+
#define MAX_EVICTED_TUPLE_SIZE 100
51+
//#define MAX_EVICTED_TUPLE_SIZE 1060
5152
//#define MAX_EVICTED_TUPLE_SIZE 2500
5253

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

21042105
// copy the tuple offsets into an array
21052106
int num_tuples = 0;
21062107
for(vector<int32_t>::iterator itr = m_evicted_offsets_sync.begin(); itr != m_evicted_offsets_sync.end(); ++itr) {
2107-
VOLT_TRACE("Marking tuple %d from %s as being needed for uneviction", *itr, m_evicted_tables_sync[num_tuples]->name().c_str());
2108+
VOLT_DEBUG("Marking tuple %d from %s as being needed for uneviction", *itr, m_evicted_tables_sync[num_tuples]->name().c_str());
21082109
tuple_ids[num_tuples++] = *itr;
21092110
}
21102111
// HACK

src/ee/anticache/AntiCacheEvictionManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
#define ANTICACHE_MERGE_BUFFER_SIZE 100000
4646

4747
#ifdef ANTICACHE_COUNTER
48-
#define SKETCH_WIDTH 32768
49-
#define SKETCH_MASK 32767
48+
#define SKETCH_WIDTH 262144
49+
#define SKETCH_MASK 262143
5050
//#define SKETCH_WIDTH 16384
5151
//#define SKETCH_MASK 16383
5252
//#define SKETCH_WIDTH 1048576
5353
//#define SKETCH_MASK 1048575
5454
#define SKETCH_HEIGHT 3
55-
#define SKETCH_THRESH 200
55+
#define SKETCH_THRESH 10
5656
#define SKETCH_SAMPLE_SIZE 200
5757
#endif
5858

src/ee/common/MMAPMemoryManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
pthread_mutex_t MMAPMemoryManager::m_mutex = PTHREAD_MUTEX_INITIALIZER;
4343

44-
const unsigned int DEFAULT_MMAP_SIZE = 256 * 1024 * 1024;
44+
const unsigned int DEFAULT_MMAP_SIZE = 2047 * 1024 * 1024;
4545

4646
MMAPMemoryManager::MMAPMemoryManager()
4747
: m_size(DEFAULT_MMAP_SIZE), m_allocated(0),

src/ee/execution/VoltDBEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ int VoltDBEngine::executeQuery(int64_t planfragmentId,
354354
for (int ctr = 0; ctr < ttl; ++ctr) {
355355
AbstractExecutor *executor = execsForFrag->list[ctr];
356356
PlanNodeType nodeType = executor->getPlanNode()->getPlanNodeType();
357-
//printf("nodeType: %d\n", nodeType);
357+
VOLT_TRACE("nodeType: %d\n", nodeType);
358358
if (nodeType == PLAN_NODE_TYPE_UPDATE || nodeType == PLAN_NODE_TYPE_DELETE)
359359
m_executorContext->getAntiCacheEvictionManager()->m_update_access =
360360
true;

src/ee/executors/nestloopindexexecutor.cpp

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
256256
#ifdef ANTICACHE
257257
AntiCacheEvictionManager* eviction_manager = executor_context->getAntiCacheEvictionManager();
258258
bool hasEvictedTable = (eviction_manager != NULL && inner_table->getEvictedTable() != NULL);
259+
bool blockingMergeSuccessful = false;
259260
#endif
260261

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

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

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

338345
// Tell the EvictionManager's internal tracker that we touched this mofo
339346
eviction_manager->recordEvictedAccess(inner_catalogTable, &inner_tuple);
@@ -347,13 +354,42 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
347354
// TODO: possibly an alternate codepath that simply looks through all the tuples
348355
// for evicted tuples and then see if we have any non-blockable accesses
349356
if (eviction_manager->hasBlockableEvictedAccesses()) {
350-
//VOLT_ERROR("From nestloop!");
351-
eviction_manager->blockingMerge();
357+
//VOLT_ERROR("From sync!");
358+
#ifdef ANTICACHE_COUNTER
359+
if (eviction_manager->m_update_access)
360+
#endif
361+
blockingMergeSuccessful = eviction_manager->blockingMerge();
352362
} else {
363+
//VOLT_ERROR("From abrt!");
364+
blockingMergeSuccessful = false;
353365
//eviction_manager->blockingMerge();
354366
continue;
355367
}
356368
}
369+
370+
if (blockingMergeSuccessful) {
371+
//printf("Scan from merge.\n");
372+
VOLT_TRACE("grabbing tuple again");
373+
if (m_lookupType == INDEX_LOOKUP_TYPE_EQ) {
374+
index->moveToKey(&index_values);
375+
inner_tuple = index->nextValueAtKey();
376+
} else {
377+
if (m_lookupType == INDEX_LOOKUP_TYPE_GT)
378+
index->moveToGreaterThanKey(&index_values);
379+
else
380+
index->moveToKeyOrGreater(&index_values);
381+
inner_tuple = index->nextValue();
382+
}
383+
384+
#ifdef ANTICACHE_COUNTER
385+
inner_tuple.setTempMergedFalse();
386+
#endif
387+
388+
if (inner_tuple.isNullTuple()) {
389+
VOLT_INFO("We've got a null tuple for some reason");
390+
}
391+
VOLT_TRACE("Merged Tuple: %s", m_tuple.debug(m_targetTable->name()).c_str());
392+
}
357393
#endif
358394

359395
VOLT_TRACE("inner_tuple:%s",
@@ -395,6 +431,12 @@ bool NestLoopIndexExecutor::p_execute(const NValueArray &params, ReadWriteTracke
395431
}
396432
#endif
397433
}
434+
#if defined(ANTICACHE) && defined(ANTICACHE_COUNTER)
435+
if (inner_tuple.isTempMerged()) {
436+
//printf("isTempMerged?\n");
437+
delete[] inner_tuple.address();
438+
}
439+
#endif
398440
} // WHILE
399441

400442
//

src/frontend/edu/brown/hstore/conf/HStoreConf.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ public final class SiteConf extends Conf {
634634
description="Reserved eviction time for anti-caching after warmup of the benchmark. This requires that the system "+
635635
"is compiled with ${site.anticache_warmup_eviction_enable} "+
636636
"set to true.",
637-
defaultInt = 480000,
638-
//defaultInt = 0000,
639-
//defaultInt = 30000,
637+
//defaultInt = 300000,
638+
//defaultInt = 900000,
639+
defaultInt = 0000,
640+
//defaultInt = 150000,
640641
experimental=true
641642
)
642643
public int anticache_warmup_eviction_time;

0 commit comments

Comments
 (0)