org.eclipse.jgit.internal.storage.dfs.BlockBasedFile in memory for
faster read access.
The DfsBlockCache serves as a Java based "buffer cache", loading segments of a BlockBasedFile into the JVM heap prior to use. As JGit often wants to do reads of only tiny slices of a file, the DfsBlockCache tries to smooth out these tiny reads into larger block-sized IO operations.
Its too expensive during object access to be accurate with a least recently used (LRU) algorithm. Strictly ordering every read is a lot of overhead that typically doesn't yield a corresponding benefit to the application.
The key tuple is passed through to methods as a pair of parameters rather than as a single Object, thus reducing the transient memory allocations of callers. It is more efficient to avoid the allocation, as we can't be 100% sure that a JIT would be able to stack-allocate a key tuple.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | DfsBlockCache.
Supplier for readable channel |
| pack-priv static class | |
| pack-priv static interface |
| Modifier and Type | Field and Description |
|---|---|
| private final int | blockSize
Suggested block size to read from pack files in. If a pack file does not have a native block size, this size will be used. |
| private static volatile DfsBlockCache | |
| private final int[] | cacheHotLimits
Limits of cache hot count per pack file extension. |
| private final DfsBlockCacheTable | |
| private final long | maxBytes
Maximum number of bytes the cache should hold. |
| private final long | maxStreamThroughCache
Pack files smaller than this size can be copied through the cache. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| pack-priv <T> T | |
| private DfsBlockCacheTable. | |
| public List | Returns: the list ofBlockCacheStats for all underlying caches.Get the list of |
| pack-priv int | |
| public long[] | Returns: total number of bytes in the cache, per pack file extension.Get total number of bytes in the cache, per pack file extension. |
| public long[] | Returns: number of evictions performed due to cache being full, per pack file extension.Get number of evictions performed due to cache being full, per pack file extension. |
| public long | Returns: 0..100, defining how full the cache is.Get 0..100, defining how full the cache is. |
| public long[] | Returns: number of requests for items in the cache, per pack file extension.Get number of requests for items in the cache, per pack file extension. |
| public long[] | |
| public static DfsBlockCache | |
| public long[] | Returns: number of requests for items not in the cache, per pack file extension.Get number of requests for items not in the cache, per pack file extension. |
| pack-priv DfsBlock | Returns: the object reference.the pack that "contains" the cached object. file, long offset within position, DfsReader pack of the object.current thread's reader. ctx, DfsBlockCache.supplier for channel to read fileChannelpack.Look up a cached object, creating and loading it if it doesn't exist. |
| pack-priv <T> DfsBlockCache. | Returns: the object reference.the stream key of the pack. key, long the position in the key. The default should be 0. position, DfsBlockCache.the function to load the reference. loaderLook up a cached object, creating and loading it if it doesn't exist. |
| public long[] | Returns: total number of requests (hit + miss), per pack file extension.Get total number of requests (hit + miss), per pack file extension. |
| public boolean | Returns: true if block 0 (the first block) is in the cache.the file to check. key)Quickly check if the cache contains block 0 of the given stream. |
| pack-priv void | |
| pack-priv <T> DfsBlockCache. | |
| pack-priv <T> DfsBlockCache. | |
| public static void | reconfigure(DfsBlockCacheConfig
the new window cache configuration. cfg)Modify the configuration of the window cache. |
| pack-priv boolean |
| blockSize | back to summary |
|---|---|
| private final int blockSize Suggested block size to read from pack files in. If a pack file does not have a native block size, this size will be used. If a pack file has a native size, a whole multiple of the native size will be used until it matches this size. The value for blockSize must be a power of 2. | |
| cache | back to summary |
|---|---|
| private static volatile DfsBlockCache cache | |
| cacheHotLimits | back to summary |
|---|---|
| private final int[] cacheHotLimits Limits of cache hot count per pack file extension. | |
| dfsBlockCacheTable | back to summary |
|---|---|
| private final DfsBlockCacheTable dfsBlockCacheTable | |
| maxBytes | back to summary |
|---|---|
| private final long maxBytes Maximum number of bytes the cache should hold. | |
| maxStreamThroughCache | back to summary |
|---|---|
| private final long maxStreamThroughCache Pack files smaller than this size can be copied through the cache. | |
| DfsBlockCache | back to summary |
|---|---|
| private DfsBlockCache(DfsBlockCacheConfig cfg) | |
| contains | back to summary |
|---|---|
| pack-priv boolean contains(DfsStreamKey key, long position) | |
| get | back to summary |
|---|---|
| pack-priv <T> T get(DfsStreamKey key, long position) | |
| getAggregatedBlockCacheStats | back to summary |
|---|---|
| private DfsBlockCacheTable. | |
| getAllBlockCacheStats | back to summary |
|---|---|
| public List Get the list of Useful in monitoring caches with breakdown.
| |
| getBlockSize | back to summary |
|---|---|
| pack-priv int getBlockSize() | |
| getCurrentSize | back to summary |
|---|---|
| public long[] getCurrentSize() Get total number of bytes in the cache, per pack file extension.
| |
| getEvictions | back to summary |
|---|---|
| public long[] getEvictions() Get number of evictions performed due to cache being full, per pack file extension.
| |
| getFillPercentage | back to summary |
|---|---|
| public long getFillPercentage() Get 0..100, defining how full the cache is.
| |
| getHitCount | back to summary |
|---|---|
| public long[] getHitCount() Get number of requests for items in the cache, per pack file extension.
| |
| getHitRatio | back to summary |
|---|---|
| public long[] getHitRatio() Get hit ratios
| |
| getInstance | back to summary |
|---|---|
| public static DfsBlockCache getInstance() Get the currently active DfsBlockCache.
| |
| getMissCount | back to summary |
|---|---|
| public long[] getMissCount() Get number of requests for items not in the cache, per pack file extension.
| |
| getOrLoad | back to summary |
|---|---|
| pack-priv DfsBlock getOrLoad(BlockBasedFile file, long position, DfsReader ctx, DfsBlockCache. Look up a cached object, creating and loading it if it doesn't exist.
| |
| getOrLoadRef | back to summary |
|---|---|
| pack-priv <T> DfsBlockCache. Look up a cached object, creating and loading it if it doesn't exist.
| |
| getTotalRequestCount | back to summary |
|---|---|
| public long[] getTotalRequestCount() Get total number of requests (hit + miss), per pack file extension.
| |
| hasBlock0 | back to summary |
|---|---|
| public boolean hasBlock0(DfsStreamKey key) Quickly check if the cache contains block 0 of the given stream. This can be useful for sophisticated pre-read algorithms to quickly determine if a file is likely already in cache, especially small reftables which may be smaller than a typical DFS block size.
| |
| put | back to summary |
|---|---|
| pack-priv void put(DfsBlock v) | |
| put | back to summary |
|---|---|
| pack-priv <T> DfsBlockCache. | |
| putRef | back to summary |
|---|---|
| pack-priv <T> DfsBlockCache. | |
| reconfigure | back to summary |
|---|---|
| public static void reconfigure(DfsBlockCacheConfig cfg) Modify the configuration of the window cache. The new configuration is applied immediately, and the existing cache is cleared.
| |
| shouldCopyThroughCache | back to summary |
|---|---|
| pack-priv boolean shouldCopyThroughCache(long length) | |
| Modifier and Type | Method and Description |
|---|---|
| public ReadableChannel |
| get | back to summary |
|---|---|
| public ReadableChannel get() throws IOException Get ReadableChannel
| |
| Modifier and Type | Field and Description |
|---|---|
| private volatile int | |
| pack-priv final DfsStreamKey | |
| pack-priv DfsBlockCache. | |
| pack-priv final long | |
| pack-priv final long | |
| private final AtomicInteger | |
| pack-priv volatile T |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv T | |
| pack-priv int | |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv void | |
| pack-priv void |
| hotCount | back to summary |
|---|---|
| private volatile int hotCount | |
| key | back to summary |
|---|---|
| pack-priv final DfsStreamKey key | |
| next | back to summary |
|---|---|
| pack-priv DfsBlockCache. | |
| position | back to summary |
|---|---|
| pack-priv final long position | |
| size | back to summary |
|---|---|
| pack-priv final long size | |
| totalHitCount | back to summary |
|---|---|
| private final AtomicInteger totalHitCount | |
| value | back to summary |
|---|---|
| pack-priv volatile T value | |
| Ref | back to summary |
|---|---|
| pack-priv Ref(DfsStreamKey key, long position, long size, T v) | |
| get | back to summary |
|---|---|
| pack-priv T get() | |
| getTotalHitCount | back to summary |
|---|---|
| pack-priv int getTotalHitCount() | |
| has | back to summary |
|---|---|
| pack-priv boolean has() | |
| isHot | back to summary |
|---|---|
| pack-priv boolean isHot() | |
| markColder | back to summary |
|---|---|
| pack-priv void markColder() | |
| markHotter | back to summary |
|---|---|
| pack-priv void markHotter() | |
| Modifier and Type | Method and Description |
|---|---|
| public DfsBlockCache. |
| load | back to summary |
|---|---|
| public DfsBlockCache. | |