|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.jgit.storage.dfs.DfsBlockCache
public final class DfsBlockCache
Caches slices of a DfsPackFile
in memory for faster read access.
The DfsBlockCache serves as a Java based "buffer cache", loading segments of a DfsPackFile 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.
Whenever a cache miss occurs, loading is invoked by exactly one thread for
the given (DfsPackKey,position)
key tuple. This is ensured by an
array of locks, with the tuple hashed to a lock instance.
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. This cache implements a clock replacement algorithm, giving each block one chance to have been accessed during a sweep of the cache to save itself from eviction.
Entities created by the cache are held under hard references, preventing the Java VM from clearing anything. Blocks are discarded by the replacement algorithm when adding a new block would cause the cache to exceed its configured maximum size.
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.
The internal hash table does not expand at runtime, instead it is fixed in size at cache creation time. The internal lock table used to gate load invocations is also fixed in size.
Method Summary | |
---|---|
long |
getCurrentSize()
|
long |
getEvictions()
|
long |
getFillPercentage()
|
long |
getHitCount()
|
long |
getHitRatio()
|
static DfsBlockCache |
getInstance()
|
long |
getMissCount()
|
Collection<DfsPackFile> |
getPackFiles()
Get the pack files stored in this cache. |
long |
getTotalRequestCount()
|
static void |
reconfigure(DfsBlockCacheConfig cfg)
Modify the configuration of the window cache. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void reconfigure(DfsBlockCacheConfig cfg)
The new configuration is applied immediately, and the existing cache is cleared.
cfg
- the new window cache configuration.
IllegalArgumentException
- the cache configuration contains one or more invalid
settings, usually too low of a limit.public static DfsBlockCache getInstance()
public long getCurrentSize()
public long getFillPercentage()
public long getHitCount()
public long getMissCount()
public long getTotalRequestCount()
public long getHitRatio()
public long getEvictions()
public Collection<DfsPackFile> getPackFiles()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |