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 2018/03/15 18:05:35 UTC

[GitHub] sijie commented on a change in pull request #1264: Refactored LAC cache in DbLedgerStorage

sijie commented on a change in pull request #1264: Refactored LAC cache in DbLedgerStorage
URL: https://github.com/apache/bookkeeper/pull/1264#discussion_r174877431
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java
 ##########
 @@ -287,23 +300,10 @@ public void initialize(ServerConfiguration conf, LedgerManager ledgerManager, Le
         ledgerIndex = new LedgerMetadataIndex(conf, KeyValueStorageRocksDB.factory, baseDir, stats);
         entryLocationIndex = new EntryLocationIndex(conf, KeyValueStorageRocksDB.factory, baseDir, stats);
 
-        // build the ledger info cache
-        int concurrencyLevel = Math.max(1, Math.max(conf.getNumAddWorkerThreads(), conf.getNumReadWorkerThreads()));
-        RemovalListener<Long, TransientLedgerInfo> ledgerInfoRemovalListener = this::handleLedgerEviction;
-        CacheBuilder<Long, TransientLedgerInfo> builder = CacheBuilder.newBuilder()
-            .initialCapacity(conf.getFileInfoCacheInitialCapacity())
-            .maximumSize(conf.getOpenFileLimit())
-            .concurrencyLevel(concurrencyLevel)
-            .removalListener(ledgerInfoRemovalListener);
-        if (conf.getFileInfoMaxIdleTime() > 0) {
-            builder.expireAfterAccess(conf.getFileInfoMaxIdleTime(), TimeUnit.SECONDS);
-        }
-        transientLedgerInfoCache = builder.build(new CacheLoader<Long, TransientLedgerInfo>() {
-            @Override
-            public TransientLedgerInfo load(Long key) throws Exception {
-                return new TransientLedgerInfo(key, ledgerIndex);
-            }
-        });
+        transientLedgerInfoCache = new ConcurrentLongHashMap<>(16 * 1024,
+                Runtime.getRuntime().availableProcessors() * 2);
 
 Review comment:
   better to configure the concurrency level to be ` Math.max(1, Math.max(conf.getNumAddWorkerThreads(), conf.getNumReadWorkerThreads()))`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services