-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29249 Allow for BlockCache implementations to define dynamic properties #6897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
77209a7
7f14a1a
378dc2f
71cead7
25beeca
660b17b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,11 +144,11 @@ public class BucketCache implements BlockCache, HeapSize { | |
| static final float DEFAULT_MEMORY_FACTOR = 0.25f; | ||
| static final float DEFAULT_MIN_FACTOR = 0.85f; | ||
|
|
||
| private static final float DEFAULT_EXTRA_FREE_FACTOR = 0.10f; | ||
| private static final float DEFAULT_ACCEPT_FACTOR = 0.95f; | ||
| static final float DEFAULT_EXTRA_FREE_FACTOR = 0.10f; | ||
| static final float DEFAULT_ACCEPT_FACTOR = 0.95f; | ||
|
|
||
| // Number of blocks to clear for each of the bucket size that is full | ||
| private static final int DEFAULT_FREE_ENTIRE_BLOCK_FACTOR = 2; | ||
| static final int DEFAULT_FREE_ENTIRE_BLOCK_FACTOR = 2; | ||
|
|
||
| /** Statistics thread */ | ||
| private static final int statThreadPeriod = 5 * 60; | ||
|
|
@@ -289,7 +289,7 @@ protected enum CacheState { | |
| private static final String DEFAULT_FILE_VERIFY_ALGORITHM = "MD5"; | ||
|
|
||
| public static final String QUEUE_ADDITION_WAIT_TIME = "hbase.bucketcache.queue.addition.waittime"; | ||
| private static final long DEFAULT_QUEUE_ADDITION_WAIT_TIME = 0; | ||
| static final long DEFAULT_QUEUE_ADDITION_WAIT_TIME = 0; | ||
| private long queueAdditionWaitTime; | ||
| /** | ||
| * Use {@link java.security.MessageDigest} class's encryption algorithms to check persistent file | ||
|
|
@@ -344,22 +344,8 @@ public BucketCache(String ioEngineName, long capacity, int blockSize, int[] buck | |
| throw new IllegalArgumentException("Cache capacity is too large, only support 32TB now"); | ||
| } | ||
|
|
||
| this.acceptableFactor = conf.getFloat(ACCEPT_FACTOR_CONFIG_NAME, DEFAULT_ACCEPT_FACTOR); | ||
| this.minFactor = conf.getFloat(MIN_FACTOR_CONFIG_NAME, DEFAULT_MIN_FACTOR); | ||
| this.extraFreeFactor = conf.getFloat(EXTRA_FREE_FACTOR_CONFIG_NAME, DEFAULT_EXTRA_FREE_FACTOR); | ||
| this.singleFactor = conf.getFloat(SINGLE_FACTOR_CONFIG_NAME, DEFAULT_SINGLE_FACTOR); | ||
| this.multiFactor = conf.getFloat(MULTI_FACTOR_CONFIG_NAME, DEFAULT_MULTI_FACTOR); | ||
| this.memoryFactor = conf.getFloat(MEMORY_FACTOR_CONFIG_NAME, DEFAULT_MEMORY_FACTOR); | ||
| this.queueAdditionWaitTime = | ||
| conf.getLong(QUEUE_ADDITION_WAIT_TIME, DEFAULT_QUEUE_ADDITION_WAIT_TIME); | ||
| this.bucketcachePersistInterval = conf.getLong(BUCKETCACHE_PERSIST_INTERVAL_KEY, 1000); | ||
| this.persistenceChunkSize = | ||
| conf.getLong(BACKING_MAP_PERSISTENCE_CHUNK_SIZE, DEFAULT_BACKING_MAP_PERSISTENCE_CHUNK_SIZE); | ||
| if (this.persistenceChunkSize <= 0) { | ||
| persistenceChunkSize = DEFAULT_BACKING_MAP_PERSISTENCE_CHUNK_SIZE; | ||
| } | ||
|
|
||
| sanityCheckConfigs(); | ||
| // these sets the dynamic configs | ||
| this.onConfigurationChange(conf); | ||
|
|
||
| LOG.info("Instantiating BucketCache with acceptableFactor: " + acceptableFactor | ||
| + ", minFactor: " + minFactor + ", extraFreeFactor: " + extraFreeFactor + ", singleFactor: " | ||
|
|
@@ -450,6 +436,9 @@ private void sanityCheckConfigs() { | |
| Preconditions.checkArgument((singleFactor + multiFactor + memoryFactor) == 1, | ||
| SINGLE_FACTOR_CONFIG_NAME + ", " + MULTI_FACTOR_CONFIG_NAME + ", and " | ||
| + MEMORY_FACTOR_CONFIG_NAME + " segments must add up to 1.0"); | ||
| if (this.persistenceChunkSize <= 0) { | ||
| persistenceChunkSize = DEFAULT_BACKING_MAP_PERSISTENCE_CHUNK_SIZE; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -911,6 +900,38 @@ boolean evictBucketEntryIfNoRpcReferenced(BlockCacheKey blockCacheKey, BucketEnt | |
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Since HBASE-29249, the following properties governin freeSpace behaviour and block priorities | ||
| * were made dynamically configurable: - hbase.bucketcache.acceptfactor - | ||
| * hbase.bucketcache.minfactor - hbase.bucketcache.extrafreefactor - | ||
| * hbase.bucketcache.single.factor - hbase.bucketcache.multi.factor - | ||
| * hbase.bucketcache.multi.factor - hbase.bucketcache.memory.factor The | ||
| * hbase.bucketcache.queue.addition.waittime property allows for introducing a delay in the | ||
| * publishing of blocks for the cache writer threads during prefetch reads only (client reads | ||
| * wouldn't get delayed). It has also been made dynamic configurable since HBASE-29249. The | ||
| * hbase.bucketcache.persist.intervalinmillis propperty determines the frequency for saving the | ||
| * persistent cache, and it has also been made dynamically configurable since HBASE-29249. The | ||
| * hbase.bucketcache.persistence.chunksize property determines the size of the persistent file | ||
| * splits (due to the limitation of maximum allowed protobuff size), and it has also been made | ||
| * dynamically configurable since HBASE-29249. | ||
| * @param config the new configuration to be updated. | ||
| */ | ||
| @Override | ||
| public void onConfigurationChange(Configuration config) { | ||
| this.acceptableFactor = conf.getFloat(ACCEPT_FACTOR_CONFIG_NAME, DEFAULT_ACCEPT_FACTOR); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haven't touch this area for a long time, all these configs can be loaded dynamically? IIRC, BucketCache will pre alloc all the memory chunks when initializing, configuration refreshing can not trigger the allocation again.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. We can't make any of the bucket allocation related properties, such as bucket sizes and cache size dynamic as those would require a reset of the cache. The properties being updated here are not related to the cache size, nor how the cache spaces are allocated, so it won't cause a cache reset.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we add a comment of javadoc on what properties could not be dynamic config? basically we changed |
||
| this.minFactor = conf.getFloat(MIN_FACTOR_CONFIG_NAME, DEFAULT_MIN_FACTOR); | ||
| this.extraFreeFactor = conf.getFloat(EXTRA_FREE_FACTOR_CONFIG_NAME, DEFAULT_EXTRA_FREE_FACTOR); | ||
| this.singleFactor = conf.getFloat(SINGLE_FACTOR_CONFIG_NAME, DEFAULT_SINGLE_FACTOR); | ||
| this.multiFactor = conf.getFloat(MULTI_FACTOR_CONFIG_NAME, DEFAULT_MULTI_FACTOR); | ||
| this.memoryFactor = conf.getFloat(MEMORY_FACTOR_CONFIG_NAME, DEFAULT_MEMORY_FACTOR); | ||
| this.queueAdditionWaitTime = | ||
| conf.getLong(QUEUE_ADDITION_WAIT_TIME, DEFAULT_QUEUE_ADDITION_WAIT_TIME); | ||
| this.bucketcachePersistInterval = conf.getLong(BUCKETCACHE_PERSIST_INTERVAL_KEY, 1000); | ||
| this.persistenceChunkSize = | ||
| conf.getLong(BACKING_MAP_PERSISTENCE_CHUNK_SIZE, DEFAULT_BACKING_MAP_PERSISTENCE_CHUNK_SIZE); | ||
| sanityCheckConfigs(); | ||
Apache9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| protected boolean removeFromRamCache(BlockCacheKey cacheKey) { | ||
| return ramCache.remove(cacheKey, re -> { | ||
| if (re != null) { | ||
|
|
@@ -2157,6 +2178,18 @@ float getMemoryFactor() { | |
| return memoryFactor; | ||
| } | ||
|
|
||
| long getQueueAdditionWaitTime() { | ||
| return queueAdditionWaitTime; | ||
| } | ||
|
|
||
| long getPersistenceChunkSize() { | ||
| return persistenceChunkSize; | ||
| } | ||
|
|
||
| long getBucketcachePersistInterval() { | ||
| return bucketcachePersistInterval; | ||
| } | ||
|
|
||
| public String getPersistencePath() { | ||
| return persistencePath; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.