Skip to content

Commit 0877e41

Browse files
author
Sourav Maji
committed
[server] Validate block-cache config against system memory
1 parent a69263a commit 0877e41

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: clients/da-vinci-client/src/main/java/com/linkedin/davinci/store/rocksdb/RocksDBStorageEngineFactory.java

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.linkedin.davinci.store.rocksdb;
22

3+
import static com.linkedin.venice.utils.ByteUtils.generateHumanReadableByteCountString;
34
import static org.rocksdb.RateLimiter.DEFAULT_FAIRNESS;
45
import static org.rocksdb.RateLimiter.DEFAULT_MODE;
56
import static org.rocksdb.RateLimiter.DEFAULT_REFILL_PERIOD_MICROS;
@@ -139,6 +140,15 @@ public RocksDBStorageEngineFactory(
139140
this.env.setBackgroundThreads(rocksDBServerConfig.getRocksDBEnvFlushPoolSize(), Priority.HIGH);
140141
this.env.setBackgroundThreads(rocksDBServerConfig.getRocksDBEnvCompactionPoolSize(), Priority.LOW);
141142

143+
long cacheBytesNeeded =
144+
rocksDBServerConfig.getRocksDBBlockCacheSizeInBytes() + (rocksDBServerConfig.isUseSeparateRMDCacheEnabled()
145+
? rocksDBServerConfig.getRocksDBRMDBlockCacheSizeInBytes()
146+
: 0);
147+
if (Runtime.getRuntime().maxMemory() * 0.8 < cacheBytesNeeded) {
148+
throw new RuntimeException(
149+
"Cannot setup rocksdb instance with block-cache size "
150+
+ generateHumanReadableByteCountString(cacheBytesNeeded));
151+
}
142152
// Shared cache across all the RocksDB databases
143153
if (RocksDBBlockCacheImplementations.CLOCK.equals(rocksDBServerConfig.getRocksDBBlockCacheImplementation())) {
144154
if (rocksDBServerConfig.isUseSeparateRMDCacheEnabled()) {

0 commit comments

Comments
 (0)