Class WindowCacheConfig

java.lang.Object
org.eclipse.jgit.storage.file.WindowCacheConfig

public class WindowCacheConfig extends Object
Configuration parameters for JVM-wide buffer cache used by JGit.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    1024 (number of bytes in one kibibyte/kilobyte)
    static final int
    1024 KB (number of bytes in one mebibyte/megabyte)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a default configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    Update properties by setting fields from the configuration.
    int
    Get maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains.
    boolean
    Tell whether the statistics JMX bean should be automatically registered.
    long
    Get maximum number bytes of heap memory to dedicate to caching pack file data.
    int
    Get maximum number of streams to open at a time.
    int
    Get size in bytes of a single window mapped or read in from the pack file.
    int
    Get the size threshold beyond which objects must be streamed.
    void
    Install this configuration as the live settings.
    boolean
    Whether to use Java NIO virtual memory mapping for windows
    boolean
    Get whether the window cache should use strong references or SoftReferences
    boolean
    Get whether the Pack indices cache should use strong references or SoftReferences
    void
    setDeltaBaseCacheLimit(int newLimit)
    Set maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains.
    void
    setExposeStatsViaJmx(boolean expose)
    Defines whether the statistics JMX MBean should be automatically set up.
    void
    setPackedGitLimit(long newLimit)
    Set maximum number bytes of heap memory to dedicate to caching pack file data.
    void
    setPackedGitMMAP(boolean usemmap)
    Set whether to enable use of Java NIO virtual memory mapping for windows
    void
    setPackedGitOpenFiles(int fdLimit)
    Set maximum number of streams to open at a time.
    void
    setPackedGitUseStrongRefs(boolean useStrongRefs)
    Set if the cache should use strong refs or soft refs
    void
    Set size in bytes of a single window read in from the pack file.
    void
    setPackedIndexGitUseStrongRefs(boolean useStrongRefs)
    Set if the Pack indices cache should use strong refs or soft refs
    void
    setStreamFileThreshold(int newLimit)
    Set new byte limit for objects that must be streamed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • KB

      public static final int KB
      1024 (number of bytes in one kibibyte/kilobyte)
      See Also:
    • MB

      public static final int MB
      1024 KB (number of bytes in one mebibyte/megabyte)
      See Also:
  • Constructor Details

    • WindowCacheConfig

      public WindowCacheConfig()
      Create a default configuration.
  • Method Details

    • getPackedGitOpenFiles

      public int getPackedGitOpenFiles()
      Get maximum number of streams to open at a time.
      Returns:
      maximum number of streams to open at a time. Open packs count against the process limits. Default is 128.
    • setPackedGitOpenFiles

      public void setPackedGitOpenFiles(int fdLimit)
      Set maximum number of streams to open at a time.
      Parameters:
      fdLimit - maximum number of streams to open at a time. Open packs count against the process limits
    • getPackedGitLimit

      public long getPackedGitLimit()
      Get maximum number bytes of heap memory to dedicate to caching pack file data.
      Returns:
      maximum number bytes of heap memory to dedicate to caching pack file data. Default is 10 MB.
    • setPackedGitLimit

      public void setPackedGitLimit(long newLimit)
      Set maximum number bytes of heap memory to dedicate to caching pack file data.
      Parameters:
      newLimit - maximum number bytes of heap memory to dedicate to caching pack file data.
    • isPackedGitUseStrongRefs

      public boolean isPackedGitUseStrongRefs()
      Get whether the window cache should use strong references or SoftReferences
      Returns:
      true if the window cache should use strong references, otherwise it will use SoftReferences
      Since:
      5.1.13
    • setPackedGitUseStrongRefs

      public void setPackedGitUseStrongRefs(boolean useStrongRefs)
      Set if the cache should use strong refs or soft refs
      Parameters:
      useStrongRefs - if @{code true} the cache strongly references cache pages otherwise it uses SoftReferences which can be evicted by the Java gc if heap is almost full
      Since:
      5.1.13
    • isPackedIndexGitUseStrongRefs

      public boolean isPackedIndexGitUseStrongRefs()
      Get whether the Pack indices cache should use strong references or SoftReferences
      Returns:
      true if the cached Pack indices should use strong references, otherwise it will use SoftReferences
      Since:
      6.7
    • setPackedIndexGitUseStrongRefs

      public void setPackedIndexGitUseStrongRefs(boolean useStrongRefs)
      Set if the Pack indices cache should use strong refs or soft refs
      Parameters:
      useStrongRefs - if @{code true} the Pack strongly references cached indices otherwise it uses SoftReferences which can be evicted by the Java gc if heap is almost full
      Since:
      6.7
    • getPackedGitWindowSize

      public int getPackedGitWindowSize()
      Get size in bytes of a single window mapped or read in from the pack file.
      Returns:
      size in bytes of a single window mapped or read in from the pack file. Default is 8 KB.
    • setPackedGitWindowSize

      public void setPackedGitWindowSize(int newSize)
      Set size in bytes of a single window read in from the pack file.
      Parameters:
      newSize - size in bytes of a single window read in from the pack file.
    • isPackedGitMMAP

      public boolean isPackedGitMMAP()
      Whether to use Java NIO virtual memory mapping for windows
      Returns:
      true enables use of Java NIO virtual memory mapping for windows; false reads entire window into a byte[] with standard read calls. Default false.
    • setPackedGitMMAP

      public void setPackedGitMMAP(boolean usemmap)
      Set whether to enable use of Java NIO virtual memory mapping for windows
      Parameters:
      usemmap - true enables use of Java NIO virtual memory mapping for windows; false reads entire window into a byte[] with standard read calls.
    • getDeltaBaseCacheLimit

      public int getDeltaBaseCacheLimit()
      Get maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains.
      Returns:
      maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains. Default 10 MB.
    • setDeltaBaseCacheLimit

      public void setDeltaBaseCacheLimit(int newLimit)
      Set maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains.
      Parameters:
      newLimit - maximum number of bytes to cache in delta base cache for inflated, recently accessed objects, without delta chains.
    • getStreamFileThreshold

      public int getStreamFileThreshold()
      Get the size threshold beyond which objects must be streamed.
      Returns:
      the size threshold beyond which objects must be streamed.
    • setStreamFileThreshold

      public void setStreamFileThreshold(int newLimit)
      Set new byte limit for objects that must be streamed.
      Parameters:
      newLimit - new byte limit for objects that must be streamed. Objects smaller than this size can be obtained as a contiguous byte array, while objects bigger than this size require using an ObjectStream.
    • getExposeStatsViaJmx

      public boolean getExposeStatsViaJmx()
      Tell whether the statistics JMX bean should be automatically registered.

      Registration of that bean via JMX is additionally subject to a boolean JGit-specific user config "jmx.WindowCacheStats". The bean will be registered only if this user config is true and getExposeStatsViaJmx() == true.

      By default, this returns true unless changed via setExposeStatsViaJmx(boolean).

      Returns:
      whether to expose WindowCacheStats statistics via JMX upon install()
      Since:
      5.8
    • setExposeStatsViaJmx

      public void setExposeStatsViaJmx(boolean expose)
      Defines whether the statistics JMX MBean should be automatically set up. (By default true.) If set to false, the JMX monitoring bean is not registered.
      Parameters:
      expose - whether to register the JMX Bean
      Since:
      5.8
    • fromConfig

      public WindowCacheConfig 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.

      Parameters:
      rc - configuration to read properties from.
      Returns:
      this.
      Since:
      3.0
    • install

      public void install()
      Install this configuration as the live settings.

      The new configuration is applied immediately. If the new limits are smaller than what is currently cached, older entries will be purged as soon as possible to allow the cache to meet the new limit.

      Since:
      3.0