You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/07/29 09:34:24 UTC

[GitHub] [bookkeeper] StevenLuMT commented on a diff in pull request #3432: Tuning pool concurrency

StevenLuMT commented on code in PR #3432:
URL: https://github.com/apache/bookkeeper/pull/3432#discussion_r933054779


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java:
##########
@@ -3858,6 +3860,50 @@ public boolean isLocalConsistencyCheckOnStartup() {
         return this.getBoolean(LOCAL_CONSISTENCY_CHECK_ON_STARTUP, false);
     }
 
+    /**
+     * The configured pooling concurrency for the allocator, if user config it, we should consider the unpooled
+     * direct memory which readCache and writeCache occupy when use DbLedgerStorage.
+     */
+    public int getAllocatorPoolingConcurrency() {
+        Integer allocatorPoolingConcurrency = this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, null);
+        if (allocatorPoolingConcurrency != null) {
+            return allocatorPoolingConcurrency;
+        }
+        String ledgerStorageClass = getLedgerStorageClass();
+        if (DbLedgerStorage.class.getName().equals(ledgerStorageClass)) {
+            long writeCacheMb;
+            Object writeCacheConf = this.getProperty(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
+            if (writeCacheConf instanceof Number) {
+                writeCacheMb =  ((Number) writeCacheConf).longValue();
+            } else if (writeCacheConf == null) {
+                writeCacheMb =  DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
+            } else if (StringUtils.isEmpty(this.getString(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB))) {
+                writeCacheMb =  DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
+            } else {
+                writeCacheMb =  this.getLong(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
+            }

Review Comment:
   Good suggestion, I green with @dlg99 
   1) move DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB to ServerConfiguration.DEFAULT_WRITE_CACHE_MAX_SIZE_MB
   
   2) use new code 
   ```
   long writeCacheMaxSize = getLongVariableOrDefault(conf, WRITE_CACHE_MAX_SIZE_MB, conf.getAllocatorPoolingConcurrency()) * MB; 
   long readCacheMaxSize = getLongVariableOrDefault(conf, READ_AHEAD_CACHE_MAX_SIZE_MB, conf.getAllocatorPoolingConcurrency()) * MB;
   ```
   
   instead of 
   ```
   long writeCacheMaxSize = getLongVariableOrDefault(conf, WRITE_CACHE_MAX_SIZE_MB, DEFAULT_WRITE_CACHE_MAX_SIZE_MB) * MB; 
   long readCacheMaxSize = getLongVariableOrDefault(conf, READ_AHEAD_CACHE_MAX_SIZE_MB, DEFAULT_READ_CACHE_MAX_SIZE_MB) * MB;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org