Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.storage.dfs

public Class DfsBlockCacheConfig

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.lib.ConfigConstants.CONFIG_CORE_SECTION, .ConfigConstants.CONFIG_DFS_CACHE_PREFIX, .ConfigConstants.CONFIG_DFS_SECTION, .ConfigConstants.CONFIG_KEY_BLOCK_LIMIT, .ConfigConstants.CONFIG_KEY_BLOCK_SIZE, .ConfigConstants.CONFIG_KEY_CONCURRENCY_LEVEL, .ConfigConstants.CONFIG_KEY_PACK_EXTENSIONS, .ConfigConstants.CONFIG_KEY_STREAM_RATIO

Configuration parameters for org.eclipse.jgit.internal.storage.dfs.DfsBlockCache.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DfsBlockCacheConfig.DfsBlockCachePackExtConfig

A configuration for a single cache table storing 1 or more Pack extensions.

public static interface
DfsBlockCacheConfig.IndexEventConsumer

Consumer of DfsBlockCache loading and eviction events for indexes.

Field Summary

Modifier and TypeField and Description
private long
private int
private Map<PackExt, Integer>
private int
public static final int
DEFAULT_CACHE_HOT_MAX

Default number of max cache hits.

pack-priv static final String
private DfsBlockCacheConfig.IndexEventConsumer
public static final int
KB

1024 (number of bytes in one kibibyte/kilobyte)

public static final int
MB

1024 KB (number of bytes in one mebibyte/megabyte)

private String
private List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig>
private Consumer<Long>
private double

Constructor Summary

AccessConstructor and Description
public
DfsBlockCacheConfig()

Create a default configuration.

Method Summary

Modifier and TypeMethod and Description
public DfsBlockCacheConfig

Returns:

this
fromConfig
(Config
configuration to read properties from.
rc
)

Update properties by setting fields from the configuration.

private void
fromConfig(String section, String subSection, Config rc)

public long

Returns:

maximum number bytes of heap memory to dedicate to caching pack file data. Default is 32 MB.
getBlockLimit
()

Get maximum number bytes of heap memory to dedicate to caching pack file data.

public int

Returns:

size in bytes of a single window mapped or read in from the pack file. Default is 64 KB.
getBlockSize
()

Get size in bytes of a single window mapped or read in from the pack file.

public Map<PackExt, Integer>

Returns:

map of hot count per pack extension for DfsBlockCache.
getCacheHotMap
()

Get the map of hot count per pack extension for DfsBlockCache.

public int

Returns:

the estimated number of threads concurrently accessing the cache. Default is 32.
getConcurrencyLevel
()

Get the estimated number of threads concurrently accessing the cache.

public DfsBlockCacheConfig.IndexEventConsumer

Returns:

consumer of cache index events.
getIndexEventConsumer
()

Get the consumer of cache index events.

public String

Returns:

the name for the block cache configured by this cache config.
getName
()

Get the name for the block cache configured by this cache config.

pack-priv List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig>

Returns:

the list of pack ext cache configs.
getPackExtCacheConfigurations
()

Get the list of pack ext cache configs.

public Consumer<Long>

Returns:

consumer of wait time in milliseconds.
getRefLockWaitTimeConsumer
()

Get the consumer of the object reference lock wait time in milliseconds.

public double

Returns:

highest percentage of getBlockLimit() a single pack can occupy while being copied by the pack reuse strategy. Default is 0.30, or 30%.
getStreamRatio
()

Get highest percentage of getBlockLimit() a single pack can occupy while being copied by the pack reuse strategy.

private static <T> Set<T>
intersection(Set<T> first, Set<T> second)

private void
public DfsBlockCacheConfig

Returns:

this
setBlockLimit
(long
maximum number bytes of heap memory to dedicate to caching pack file data; must be positive.
newLimit
)

Set maximum number bytes of heap memory to dedicate to caching pack file data.

public DfsBlockCacheConfig

Returns:

this
setBlockSize
(int
size in bytes of a single window read in from the pack file. The value must be a power of 2.
newSize
)

Set size in bytes of a single window read in from the pack file.

public DfsBlockCacheConfig

Returns:

this
setCacheHotMap
(Map<PackExt, Integer>
map of hot count per pack extension for DfsBlockCache.
cacheHotMap
)

Set the map of hot count per pack extension for DfsBlockCache.

private void
public DfsBlockCacheConfig

Returns:

this
setConcurrencyLevel
(final int
the estimated number of threads concurrently accessing the cache.
newConcurrencyLevel
)

Set the estimated number of threads concurrently accessing the cache.

public DfsBlockCacheConfig

Returns:

this
setIndexEventConsumer
(DfsBlockCacheConfig.IndexEventConsumer
consumer of cache index events.
indexEventConsumer
)

Set the consumer of cache index events.

pack-priv DfsBlockCacheConfig

Returns:

this
setName
(String
the name for the block cache configured by this cache config.
name
)

Set the name for the block cache configured by this cache config.

pack-priv DfsBlockCacheConfig

Returns:

this
setPackExtCacheConfigurations
(List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig>
the list of pack ext cache configs to set.
packExtCacheConfigurations
)

Set the list of pack ext cache configs.

public DfsBlockCacheConfig

Returns:

this
setRefLockWaitTimeConsumer
(Consumer<Long>
consumer of wait time in milliseconds.
c
)

Set the consumer for lock wait time.

public DfsBlockCacheConfig

Returns:

this
setStreamRatio
(double
percentage of cache to occupy with a copied pack.
ratio
)

Set percentage of cache to occupy with a copied pack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockLimitback to summary
private long blockLimit
blockSizeback to summary
private int blockSize
cacheHotMapback to summary
private Map<PackExt, Integer> cacheHotMap
concurrencyLevelback to summary
private int concurrencyLevel
DEFAULT_CACHE_HOT_MAXback to summary
public static final int DEFAULT_CACHE_HOT_MAX

Default number of max cache hits.

DEFAULT_NAMEback to summary
pack-priv static final String DEFAULT_NAME
indexEventConsumerback to summary
private DfsBlockCacheConfig.IndexEventConsumer indexEventConsumer
KBback to summary
public static final int KB

1024 (number of bytes in one kibibyte/kilobyte)

MBback to summary
public static final int MB

1024 KB (number of bytes in one mebibyte/megabyte)

nameback to summary
private String name
packExtCacheConfigurationsback to summary
private List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig> packExtCacheConfigurations
refLockback to summary
private Consumer<Long> refLock
streamRatioback to summary
private double streamRatio

Constructor Detail

DfsBlockCacheConfigback to summary
public DfsBlockCacheConfig()

Create a default configuration.

Method Detail

fromConfigback to summary
public DfsBlockCacheConfig fromConfig(Config rc)

Update properties by setting fields from the configuration.

If a property is not defined in the configuration, then it is left unmodified.

Enforces certain constraints on the combination of settings in the config, for example that the block limit is a multiple of the block size.

Parameters
rc:Config

configuration to read properties from.

Returns:DfsBlockCacheConfig

this

fromConfigback to summary
private void fromConfig(String section, String subSection, Config rc)
getBlockLimitback to summary
public long getBlockLimit()

Get maximum number bytes of heap memory to dedicate to caching pack file data.

Returns:long

maximum number bytes of heap memory to dedicate to caching pack file data. Default is 32 MB.

getBlockSizeback to summary
public int getBlockSize()

Get size in bytes of a single window mapped or read in from the pack file.

Returns:int

size in bytes of a single window mapped or read in from the pack file. Default is 64 KB.

getCacheHotMapback to summary
public Map<PackExt, Integer> getCacheHotMap()

Get the map of hot count per pack extension for DfsBlockCache.

Returns:Map<PackExt, Integer>

map of hot count per pack extension for DfsBlockCache.

getConcurrencyLevelback to summary
public int getConcurrencyLevel()

Get the estimated number of threads concurrently accessing the cache.

Returns:int

the estimated number of threads concurrently accessing the cache. Default is 32.

getIndexEventConsumerback to summary
public DfsBlockCacheConfig.IndexEventConsumer getIndexEventConsumer()

Get the consumer of cache index events.

Returns:DfsBlockCacheConfig.IndexEventConsumer

consumer of cache index events.

getNameback to summary
public String getName()

Get the name for the block cache configured by this cache config.

Returns:String

the name for the block cache configured by this cache config.

getPackExtCacheConfigurationsback to summary
pack-priv List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig> getPackExtCacheConfigurations()

Get the list of pack ext cache configs.

Returns:List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig>

the list of pack ext cache configs.

getRefLockWaitTimeConsumerback to summary
public Consumer<Long> getRefLockWaitTimeConsumer()

Get the consumer of the object reference lock wait time in milliseconds.

Returns:Consumer<Long>

consumer of wait time in milliseconds.

getStreamRatioback to summary
public double getStreamRatio()

Get highest percentage of getBlockLimit() a single pack can occupy while being copied by the pack reuse strategy.

Returns:double

highest percentage of getBlockLimit() a single pack can occupy while being copied by the pack reuse strategy. Default is 0.30, or 30%.

intersectionback to summary
private static <T> Set<T> intersection(Set<T> first, Set<T> second)
loadPackExtConfigsback to summary
private void loadPackExtConfigs(Config config)
setBlockLimitback to summary
public DfsBlockCacheConfig setBlockLimit(long newLimit)

Set maximum number bytes of heap memory to dedicate to caching pack file data.

It is strongly recommended to set the block limit to be an integer multiple of the block size. This constraint is not enforced by this method (since it may be called before setBlockSize(int)), but it is enforced by fromConfig(Config).

Parameters
newLimit:long

maximum number bytes of heap memory to dedicate to caching pack file data; must be positive.

Returns:DfsBlockCacheConfig

this

setBlockSizeback to summary
public DfsBlockCacheConfig setBlockSize(int newSize)

Set size in bytes of a single window read in from the pack file.

Parameters
newSize:int

size in bytes of a single window read in from the pack file. The value must be a power of 2.

Returns:DfsBlockCacheConfig

this

setCacheHotMapback to summary
public DfsBlockCacheConfig setCacheHotMap(Map<PackExt, Integer> cacheHotMap)

Set the map of hot count per pack extension for DfsBlockCache.

Parameters
cacheHotMap:Map<PackExt, Integer>

map of hot count per pack extension for DfsBlockCache.

Returns:DfsBlockCacheConfig

this

setCacheHotMapToPackExtConfigsback to summary
private void setCacheHotMapToPackExtConfigs(Map<PackExt, Integer> cacheHotMap)
setConcurrencyLevelback to summary
public DfsBlockCacheConfig setConcurrencyLevel(final int newConcurrencyLevel)

Set the estimated number of threads concurrently accessing the cache.

Parameters
newConcurrencyLevel:int

the estimated number of threads concurrently accessing the cache.

Returns:DfsBlockCacheConfig

this

setIndexEventConsumerback to summary
public DfsBlockCacheConfig setIndexEventConsumer(DfsBlockCacheConfig.IndexEventConsumer indexEventConsumer)

Set the consumer of cache index events.

Parameters
indexEventConsumer:DfsBlockCacheConfig.IndexEventConsumer

consumer of cache index events.

Returns:DfsBlockCacheConfig

this

setNameback to summary
pack-priv DfsBlockCacheConfig setName(String name)

Set the name for the block cache configured by this cache config.

Made visible for testing.

Parameters
name:String

the name for the block cache configured by this cache config.

Returns:DfsBlockCacheConfig

this

setPackExtCacheConfigurationsback to summary
pack-priv DfsBlockCacheConfig setPackExtCacheConfigurations(List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig> packExtCacheConfigurations)

Set the list of pack ext cache configs. Made visible for testing.

Parameters
packExtCacheConfigurations:List<DfsBlockCacheConfig.DfsBlockCachePackExtConfig>

the list of pack ext cache configs to set.

Returns:DfsBlockCacheConfig

this

setRefLockWaitTimeConsumerback to summary
public DfsBlockCacheConfig setRefLockWaitTimeConsumer(Consumer<Long> c)

Set the consumer for lock wait time.

Parameters
c:Consumer<Long>

consumer of wait time in milliseconds.

Returns:DfsBlockCacheConfig

this

setStreamRatioback to summary
public DfsBlockCacheConfig setStreamRatio(double ratio)

Set percentage of cache to occupy with a copied pack.

Parameters
ratio:double

percentage of cache to occupy with a copied pack.

Returns:DfsBlockCacheConfig

this

org.eclipse.jgit.internal.storage.dfs back to summary

pack-priv Class DfsBlockCacheConfig.DfsBlockCachePackExtConfig

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheConfig.DfsBlockCachePackExtConfig

A configuration for a single cache table storing 1 or more Pack extensions.

The current pack ext cache tables implementation supports the same parameters the ClockBlockCacheTable (current default implementation).

Configuration falls back to the defaults coded values defined in the DfsBlockCacheConfig when not set on each cache table configuration and NOT the values of the basic dfs section.

Format: [core "dfs.packCache"] packExtensions = "PACK" blockSize = 512 blockLimit = 100 concurrencyLevel = 5 [core "dfs.multipleExtensionCache"] packExtensions = "INDEX REFTABLE BITMAP_INDEX" blockSize = 512 blockLimit = 100 concurrencyLevel = 5

Field Summary

Modifier and TypeField and Description
private final DfsBlockCacheConfig
private final EnumSet<PackExt>

Constructor Summary

AccessConstructor and Description
pack-priv
DfsBlockCachePackExtConfig(EnumSet<PackExt>
Set of PackExts associated to this cache config.
packExts
,
DfsBlockCacheConfig
DfsBlockCacheConfig for this cache config.
packExtCacheConfiguration
)

Made visible for testing.

Method Summary

Modifier and TypeMethod and Description
private static DfsBlockCacheConfig.DfsBlockCachePackExtConfig
fromConfig(Config config, String section, String subSection)

pack-priv DfsBlockCacheConfig
pack-priv Set<PackExt>
pack-priv void
print(String linePrefix, String pad, PrintWriter writer)

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

packExtCacheConfigurationback to summary
private final DfsBlockCacheConfig packExtCacheConfiguration
packExtsback to summary
private final EnumSet<PackExt> packExts

Constructor Detail

DfsBlockCachePackExtConfigback to summary
pack-priv DfsBlockCachePackExtConfig(EnumSet<PackExt> packExts, DfsBlockCacheConfig packExtCacheConfiguration)

Made visible for testing.

Parameters
packExts:EnumSet<PackExt>

Set of PackExts associated to this cache config.

packExtCacheConfiguration:DfsBlockCacheConfig

DfsBlockCacheConfig for this cache config.

Method Detail

fromConfigback to summary
private static DfsBlockCacheConfig.DfsBlockCachePackExtConfig fromConfig(Config config, String section, String subSection)
getPackExtCacheConfigurationback to summary
pack-priv DfsBlockCacheConfig getPackExtCacheConfiguration()
getPackExtsback to summary
pack-priv Set<PackExt> getPackExts()
printback to summary
pack-priv void print(String linePrefix, String pad, PrintWriter writer)
setCacheHotMapback to summary
pack-priv void setCacheHotMap(Map<PackExt, Integer> cacheHotMap)
org.eclipse.jgit.internal.storage.dfs back to summary

public Interface DfsBlockCacheConfig.IndexEventConsumer


Consumer of DfsBlockCache loading and eviction events for indexes.

Method Summary

Modifier and TypeMethod and Description
public default void
acceptEvictedEvent(int
position in PackExt enum
packExtPos
,
long
number of bytes evicted
bytes
,
int
number of times an index was accessed while in cache
totalCacheHitCount
,
Duration
time since last eviction, 0 if was not evicted yet
lastEvictionDuration
)

Accept an event of an index evicted from cache.

public void
acceptRequestedEvent(int
position in PackExt enum
packExtPos
,
boolean
true if an index was already in cache. Otherwise, the index was loaded from storage into the cache in the current request,
cacheHit
,
long
time to load an index from cache or storage in microseconds
loadMicros
,
long
number of bytes loaded
bytes
,
Duration
time since last eviction, 0 if was not evicted yet
lastEvictionDuration
)

Accept an event of an index requested.

public default boolean

Returns:

true if reporting evicted events is enabled.
shouldReportEvictedEvent
()

Whether evicted events should be reported

Method Detail

acceptEvictedEventback to summary
public default void acceptEvictedEvent(int packExtPos, long bytes, int totalCacheHitCount, Duration lastEvictionDuration)

Accept an event of an index evicted from cache.

Parameters
packExtPos:int

position in PackExt enum

bytes:long

number of bytes evicted

totalCacheHitCount:int

number of times an index was accessed while in cache

lastEvictionDuration:Duration

time since last eviction, 0 if was not evicted yet

acceptRequestedEventback to summary
public void acceptRequestedEvent(int packExtPos, boolean cacheHit, long loadMicros, long bytes, Duration lastEvictionDuration)

Accept an event of an index requested. It could be loaded from either cache or storage.

Parameters
packExtPos:int

position in PackExt enum

cacheHit:boolean

true if an index was already in cache. Otherwise, the index was loaded from storage into the cache in the current request,

loadMicros:long

time to load an index from cache or storage in microseconds

bytes:long

number of bytes loaded

lastEvictionDuration:Duration

time since last eviction, 0 if was not evicted yet

shouldReportEvictedEventback to summary
public default boolean shouldReportEvictedEvent()

Whether evicted events should be reported

Returns:boolean

true if reporting evicted events is enabled.