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

Commit 063e024

Browse files
committed
Add throttling to anti-cache retrieval for unblocking clients.
1 parent f98327b commit 063e024

File tree

7 files changed

+32
-7
lines changed

7 files changed

+32
-7
lines changed

src/ee/anticache/AntiCacheEvictionManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ AntiCacheEvictionManager::AntiCacheEvictionManager(const VoltDBEngine *engine) {
9090
m_migrate = false;
9191

9292

93+
if (pthread_mutex_init(&lock, NULL) != 0) {
94+
VOLT_ERROR("Mutex init failed!");
95+
}
96+
9397
if (pthread_mutex_init(&(prio_lock.cv_mutex), NULL) != 0) {
9498
VOLT_ERROR("Mutex init failed!");
9599
}
@@ -112,6 +116,8 @@ AntiCacheEvictionManager::~AntiCacheEvictionManager() {
112116
delete m_evicted_tuple;
113117
TupleSchema::freeTupleSchema(m_evicted_schema);
114118

119+
pthread_mutex_destroy(&lock);
120+
115121
pthread_mutex_destroy(&prio_lock.cv_mutex);
116122
pthread_mutex_destroy(&prio_lock.cs_mutex);
117123
pthread_cond_destroy(&prio_lock.cond);
@@ -1364,6 +1370,7 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
13641370
VOLT_DEBUG("num tuples is %d", tuples);
13651371
}
13661372

1373+
//pthread_mutex_lock(&lock);
13671374
table->insertUnevictedBlock(unevicted_tuples, table->m_read_pivot);
13681375
table->insertTupleOffset(tuple_offset, table->m_read_pivot);
13691376
table->insertBlockID(block_id, table->m_read_pivot);
@@ -1373,6 +1380,7 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
13731380
}
13741381
else
13751382
table->m_read_pivot++;
1383+
//pthread_mutex_unlock(&lock);
13761384

13771385
//if (table->m_read_pivot % 10000 == 0)
13781386

src/ee/anticache/AntiCacheEvictionManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ class AntiCacheEvictionManager {
198198
std::vector<int32_t> m_evicted_block_ids_sync;
199199
std::vector<int32_t> m_evicted_offsets_sync;
200200

201+
pthread_mutex_t lock;
202+
201203
std::map <int32_t, set <int32_t> > m_evicted_filter;
202204
// whether the block to be merged is blockable, that is, all blocks that are needed
203205
// are in blockable tiers

src/ee/anticache/BerkeleyAntiCacheDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void BerkeleyAntiCacheDB::initializeDB() {
7272
//DB_AUTO_COMMIT | // Immediately commit every operation
7373
DB_INIT_MPOOL | // Initialize the memory pool (in-memory cache)
7474
// DB_TXN_NOSYNC | // Don't flush to disk every time, we will do that explicitly
75-
DB_INIT_LOCK | // concurrent data store
75+
//DB_INIT_LOCK | // concurrent data store
7676
//DB_PRIVATE |
7777
DB_THREAD | // allow multiple threads
7878
// DB_INIT_TXN |

src/frontend/edu/brown/hstore/AntiCacheManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public String toString() {
133133
private final double UNEVICTION_RATIO_CLUSTER_THRESHOLD = .1;
134134
private final double ACCESS_RATE_CLUSTER_THRESHOLD = .1;
135135

136+
private final long throttleThreshold;
137+
136138
/**
137139
*
138140
*/
@@ -286,6 +288,8 @@ public void update(EventObservable<VoltTable> o, VoltTable vt) {
286288

287289
numDBs = levels.length;
288290
}
291+
292+
this.throttleThreshold = hstore_conf.client.blocking_concurrent * hstore_site.getLocalPartitionIds().size() / 8 * 3;
289293
}
290294

291295
public Collection<Table> getEvictableTables() {
@@ -296,6 +300,10 @@ public Runnable getMemoryMonitorThread() {
296300
return this.memoryMonitor;
297301
}
298302

303+
public boolean checkQueueBound() {
304+
return this.queue.size() < this.throttleThreshold;
305+
}
306+
299307

300308
// ----------------------------------------------------------------------------
301309
// TRANSACTION PROCESSING

src/frontend/edu/brown/hstore/HStoreSite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,7 @@ public void responseSend(LocalTransaction ts, ClientResponseImpl cresponse) {
27692769
"The client handle for " + ts + " was not set properly";
27702770
assert(status != Status.ABORT_MISPREDICT && status != Status.ABORT_EVICTEDACCESS) :
27712771
"Trying to send back a client response for " + ts + " but the status is " + status;
2772-
2772+
27732773
if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startPostClient();
27742774
boolean sendResponse = true;
27752775

src/frontend/edu/brown/hstore/PartitionExecutor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,9 +4587,16 @@ protected void processClientResponse(LocalTransaction ts, ClientResponseImpl cre
45874587
if (ts.isPredictSinglePartition()) {
45884588
if (ts.isMarkedFinished(this.partitionId) == false)
45894589
this.finishTransaction(ts, status);
4590-
//this.hstore_site.responseSend(ts, cresponse);
4591-
//this.hstore_site.transactionRequeue(ts, status);
4592-
this.hstore_site.transactionRestart(ts, status);
4590+
if (this.hstore_site.getAntiCacheManager().checkQueueBound()) {
4591+
this.hstore_site.transactionRequeue(ts, status);
4592+
// this.hstore_site.transactionRestart(ts, status);
4593+
}
4594+
else {
4595+
if (hstore_conf.site.exec_profiling) this.profiler.network_time.start();
4596+
this.hstore_site.responseSend(ts, cresponse);
4597+
if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();
4598+
this.hstore_site.queueDeleteTransaction(ts.getTransactionId(), status);
4599+
}
45934600
}
45944601
// Send a message all the partitions involved that the party is over
45954602
// and that they need to abort the transaction. We don't actually care when we get the

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,9 @@ 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 = 450000,
637+
defaultInt = 480000,
638638
//defaultInt = 0000,
639-
defaultInt = 10000,
639+
//defaultInt = 30000,
640640
experimental=true
641641
)
642642
public int anticache_warmup_eviction_time;

0 commit comments

Comments
 (0)