Browse Source

Add "concurrencyLevel" option to DfsBlockCache

Allow for higher concurrency on DfsBlockCache by adding a configuration
for number of estimated concurrent requests.

Change-Id: Ia65e58ecb2c459b6d9c9697a2f715d933270f7e6
Signed-off-by: Philipp Marx <smigfu@googlemail.com>
stable-4.6
Philipp Marx 8 years ago committed by David Pursehouse
parent
commit
ccc899773e
  1. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
  2. 31
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java
  3. 7
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java

@ -182,7 +182,7 @@ public final class DfsBlockCache {
throw new IllegalArgumentException(JGitText.get().tSizeMustBeGreaterOrEqual1);
table = new AtomicReferenceArray<HashEntry>(tableSize);
loadLocks = new ReentrantLock[32];
loadLocks = new ReentrantLock[cfg.getConcurrencyLevel()];
for (int i = 0; i < loadLocks.length; i++)
loadLocks[i] = new ReentrantLock(true /* fair */);

31
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfig.java

@ -47,6 +47,7 @@ import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_CORE_SECTION;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_DFS_SECTION;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BLOCK_LIMIT;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BLOCK_SIZE;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_CONCURRENCY_LEVEL;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_STREAM_RATIO;
import java.text.MessageFormat;
@ -65,12 +66,14 @@ public class DfsBlockCacheConfig {
private long blockLimit;
private int blockSize;
private double streamRatio;
private int concurrencyLevel;
/** Create a default configuration. */
public DfsBlockCacheConfig() {
setBlockLimit(32 * MB);
setBlockSize(64 * KB);
setStreamRatio(0.30);
setConcurrencyLevel(32);
}
/**
@ -110,6 +113,28 @@ public class DfsBlockCacheConfig {
return this;
}
/**
* @return the estimated number of threads concurrently accessing the cache.
* <b>Default is 32.</b>
* @since 4.6
*/
public int getConcurrencyLevel() {
return concurrencyLevel;
}
/**
* @param newConcurrencyLevel
* the estimated number of threads concurrently accessing the
* cache.
* @return {@code this}
* @since 4.6
*/
public DfsBlockCacheConfig setConcurrencyLevel(
final int newConcurrencyLevel) {
concurrencyLevel = newConcurrencyLevel;
return this;
}
/**
* @return highest percentage of {@link #getBlockLimit()} a single pack can
* occupy while being copied by the pack reuse strategy. <b>Default
@ -154,6 +179,12 @@ public class DfsBlockCacheConfig {
CONFIG_KEY_BLOCK_SIZE,
getBlockSize()));
setConcurrencyLevel(rc.getInt(
CONFIG_CORE_SECTION,
CONFIG_DFS_SECTION,
CONFIG_KEY_CONCURRENCY_LEVEL,
getConcurrencyLevel()));
String v = rc.getString(
CONFIG_CORE_SECTION,
CONFIG_DFS_SECTION,

7
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java

@ -145,6 +145,13 @@ public class ConfigConstants {
/** The "blockSize" key */
public static final String CONFIG_KEY_BLOCK_SIZE = "blockSize";
/**
* The "concurrencyLevel" key
*
* @since 4.6
*/
public static final String CONFIG_KEY_CONCURRENCY_LEVEL = "concurrencyLevel";
/** The "deltaBaseCacheLimit" key */
public static final String CONFIG_KEY_DELTA_BASE_CACHE_LIMIT = "deltaBaseCacheLimit";

Loading…
Cancel
Save