Memory settings in Gerrit configuration Memory settings in Gerrit configuration
Memory settings in gerrit.config.
heapLimitMemory is crucial to Gerrit performance. The container.heapLimit parameter is used here. From Gerrit documentation:
container.heapLimit Maximum heap size of the Java process running Gerrit, in bytes. This property is translated into the -Xmx flag for the JVM. Default is platform and JVM specific. Common unit suffixes of k, m, or g are supported.Our default configuration does not set this parameter. So what should the default value be? According to Oracle documentation, starting from J2SE 5.0 it is the smaller of 1/4th of the physical memory or 1GB (before J2SE 5.0, the default maximum heap size was 64MB). We recommend you set this parameter to 8GB for a 16GB machine and 16GB or more for a machine with 24GB or more memory.
packedGitLimitThis is another important setting. From Gerrit documentation:
core.packedGitLimit Maximum number of bytes to load and cache in memory from pack files. If JGit needs to access more than this many bytes it will unload less frequently used windows to reclaim memory space within the process. As this buffer must be shared with the rest of the JVM heap, it should be a fraction of the total memory available. Default on JGit is 10 MiB on all platforms. Common unit suffixes of k, m, or g are supported.From this post on Gerrit performance:
We run an 8 GiB JVM heap, and of that heap we permit 2 GiB of memory to used as a buffer cache for packed Git data. By default that buffer cache is 20 MiB. If you don't raise packedGitLimit that JVM heap won't really be utilized and you will be thrasing the internal buffer cache.So it is good to increase packedGitLimit to at least 2GB. This is in keeping with the experience of our customers who use Gerrit heavily. We recommend you set this parameter to 2GB or 4GB.
core.packedGitWindowSize Number of bytes of a pack file to load into memory in a single read operation. This is the "page size" of the JGit buffer cache, used for all pack access operations. All disk IO occurs as single window reads. Setting this too large may cause the process to load more data than is required; setting this too small may increase the frequency of read() system calls. Default on JGit is 8 KiB on all platforms. Common unit suffixes of k, m, or g are supported.Suggested setting:
core.packedGitWindowSize = 16k (default is 8k)
core.packedGitOpenFiles Maximum number of pack files to have open at once. A pack file must be opened in order for any of its data to be available in a cached window. If you increase this to a larger setting you may need to also adjust the ulimit on file descriptors for the host JVM, as Gerrit needs additional file descriptors available for network sockets and other repository data manipulation. Default on JGit is 128 file descriptors on all platforms.Suggested setting:
core.packedGitOpenFiles = 4096 (default is 128)
Note: Changing this parameter may require adjusting ulimit on file descriptors for the host JVM.