blob: 668b92cf533117b6be01b04f4704d3ab65dd7d61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* Copyright (C) 2018, David Pursehouse <david.pursehouse@gmail.com> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.storage.file;
import java.util.Map;
import javax.management.MXBean;
import org.eclipse.jgit.internal.storage.file.WindowCache;
/**
* Cache statistics for {@link WindowCache}.
*
* @since 4.11
*/
@MXBean
public interface WindowCacheStats {
/**
* Get cache statistics
*
* @return cache statistics for the WindowCache
* @since 5.1.13
*/
public static WindowCacheStats getStats() {
return WindowCache.getInstance().getStats();
}
/**
* Number of cache hits
*
* @return number of cache hits
*/
long getHitCount();
/**
* Ratio of cache requests which were hits defined as
* {@code hitCount / requestCount}, or {@code 1.0} when
* {@code requestCount == 0}. Note that {@code hitRate + missRate =~ 1.0}.
*
* @return the ratio of cache requests which were hits
*/
default double getHitRatio() {
long requestCount = getRequestCount();
return (requestCount == 0) ? 1.0
: (double) getHitCount() / requestCount;
}
/**
* Number of cache misses.
*
* @return number of cash misses
*/
long getMissCount();
/**
* Ratio of cache requests which were misses defined as
* {@code missCount / requestCount}, or {@code 0.0} when
* {@code requestCount == 0}. Note that {@code hitRate + missRate =~ 1.0}.
* Cache misses include all requests which weren't cache hits, including
* requests which resulted in either successful or failed loading attempts.
*
* @return the ratio of cache requests which were misses
*/
default double getMissRatio() {
long requestCount = getRequestCount();
return (requestCount == 0) ? 0.0
: (double) getMissCount() / requestCount;
}
/**
* Number of successful loads
*
* @return number of successful loads
*/
long getLoadSuccessCount();
/**
* Number of failed loads
*
* @return number of failed loads
*/
long getLoadFailureCount();
/**
* Ratio of cache load attempts which threw exceptions. This is defined as
* {@code loadFailureCount / (loadSuccessCount + loadFailureCount)}, or
* {@code 0.0} when {@code loadSuccessCount + loadFailureCount == 0}.
*
* @return the ratio of cache loading attempts which threw exceptions
*/
default double getLoadFailureRatio() {
long loadFailureCount = getLoadFailureCount();
long totalLoadCount = getLoadSuccessCount() + loadFailureCount;
return (totalLoadCount == 0) ? 0.0
: (double) loadFailureCount / totalLoadCount;
}
/**
* Total number of times that the cache attempted to load new values. This
* includes both successful load operations, as well as failed loads. This
* is defined as {@code loadSuccessCount + loadFailureCount}.
*
* @return the {@code loadSuccessCount + loadFailureCount}
*/
default long getLoadCount() {
return getLoadSuccessCount() + getLoadFailureCount();
}
/**
* Number of cache evictions
*
* @return number of evictions
*/
long getEvictionCount();
/**
* Ratio of cache evictions. This is defined as
* {@code evictionCount / requestCount}, or {@code 0.0} when
* {@code requestCount == 0}.
*
* @return the ratio of cache loading attempts which threw exceptions
*/
default double getEvictionRatio() {
long evictionCount = getEvictionCount();
long requestCount = getRequestCount();
return (requestCount == 0) ? 0.0
: (double) evictionCount / requestCount;
}
/**
* Number of times the cache returned either a cached or uncached value.
* This is defined as {@code hitCount + missCount}.
*
* @return the {@code hitCount + missCount}
*/
default long getRequestCount() {
return getHitCount() + getMissCount();
}
/**
* Average time in nanoseconds for loading new values. This is
* {@code totalLoadTime / (loadSuccessCount + loadFailureCount)}.
*
* @return the average time spent loading new values
*/
default double getAverageLoadTime() {
long totalLoadCount = getLoadSuccessCount() + getLoadFailureCount();
return (totalLoadCount == 0) ? 0.0
: (double) getTotalLoadTime() / totalLoadCount;
}
/**
* Total time in nanoseconds the cache spent loading new values.
*
* @return the total number of nanoseconds the cache has spent loading new
* values
*/
long getTotalLoadTime();
/**
* Number of pack files kept open by the cache
*
* @return number of files kept open by cache
*/
long getOpenFileCount();
/**
* Number of bytes cached
*
* @return number of bytes cached
*/
long getOpenByteCount();
/**
* Number of bytes cached per repository
*
* @return number of bytes cached per repository
*/
Map<String, Long> getOpenByteCountPerRepository();
/**
* Reset counters. Does not reset open bytes and open files counters.
*/
void resetCounters();
}
|