diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-11-30 03:38:13 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-12-08 01:09:24 +0100 |
commit | 42f0c7c9cb1c516603da6f89ae7072989bf4b984 (patch) | |
tree | 9ea227a86c49c7602d2cbdbdfc2070e1cbb69bb5 /org.eclipse.jgit.test | |
parent | 7554bdfad5be0eff0b95dcfcec11a2cb19883b18 (diff) | |
download | jgit-42f0c7c9cb1c516603da6f89ae7072989bf4b984.tar.gz jgit-42f0c7c9cb1c516603da6f89ae7072989bf4b984.zip |
Enhance WindowCache statistics
Add the following statistics
- cache hit count and hit ratio
- cache miss count and miss ratio
- count of successful and failed loads
- rate of failed loads
- load, eviction and request count
- average and total load time
Use LongAdder instead of AtomicLong to implement counters in order to
improve scalability.
Optionally expose these metrics via JMX, they are registered with the
platform MBean server if the config option jmx.WindowCacheStats = true
in the user or system level git config.
Bug: 553573
Change-Id: Ia2d5246ef69b9c2bd594a23934424bc5800774aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java index 9063b65189..f1a18b096c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java @@ -61,6 +61,7 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.storage.file.WindowCacheConfig; +import org.eclipse.jgit.storage.file.WindowCacheStats; import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase; import org.eclipse.jgit.util.MutableInteger; import org.junit.Before; @@ -102,8 +103,21 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase { checkLimits(cfg); final WindowCache cache = WindowCache.getInstance(); - assertEquals(6, cache.getOpenFiles()); - assertEquals(17346, cache.getOpenBytes()); + WindowCacheStats s = cache.getStats(); + assertEquals(6, s.getOpenFileCount()); + assertEquals(17346, s.getOpenByteCount()); + assertEquals(0, s.getEvictionCount()); + assertEquals(90, s.getHitCount()); + assertTrue(s.getHitRatio() > 0.0 && s.getHitRatio() < 1.0); + assertEquals(6, s.getLoadCount()); + assertEquals(0, s.getLoadFailureCount()); + assertEquals(0, s.getLoadFailureRatio(), 0.001); + assertEquals(6, s.getLoadSuccessCount()); + assertEquals(6, s.getMissCount()); + assertTrue(s.getMissRatio() > 0.0 && s.getMissRatio() < 1.0); + assertEquals(96, s.getRequestCount()); + assertTrue(s.getAverageLoadTime() > 0.0); + assertTrue(s.getTotalLoadTime() > 0.0); } @Test @@ -127,10 +141,27 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase { private static void checkLimits(WindowCacheConfig cfg) { final WindowCache cache = WindowCache.getInstance(); - assertTrue(cache.getOpenFiles() <= cfg.getPackedGitOpenFiles()); - assertTrue(cache.getOpenBytes() <= cfg.getPackedGitLimit()); - assertTrue(0 < cache.getOpenFiles()); - assertTrue(0 < cache.getOpenBytes()); + WindowCacheStats s = cache.getStats(); + assertTrue(0 < s.getAverageLoadTime()); + assertTrue(0 < s.getOpenByteCount()); + assertTrue(0 < s.getOpenByteCount()); + assertTrue(0.0 < s.getAverageLoadTime()); + assertTrue(0 <= s.getEvictionCount()); + assertTrue(0 < s.getHitCount()); + assertTrue(0 < s.getHitRatio()); + assertTrue(1 > s.getHitRatio()); + assertTrue(0 < s.getLoadCount()); + assertTrue(0 <= s.getLoadFailureCount()); + assertTrue(0.0 <= s.getLoadFailureRatio()); + assertTrue(1 > s.getLoadFailureRatio()); + assertTrue(0 < s.getLoadSuccessCount()); + assertTrue(s.getOpenByteCount() <= cfg.getPackedGitLimit()); + assertTrue(s.getOpenFileCount() <= cfg.getPackedGitOpenFiles()); + assertTrue(0 <= s.getMissCount()); + assertTrue(0 <= s.getMissRatio()); + assertTrue(1 > s.getMissRatio()); + assertTrue(0 < s.getRequestCount()); + assertTrue(0 < s.getTotalLoadTime()); } private void doCacheTests() throws IOException { |