1 /*
2 * Copyright (C) 2017, Google Inc. and others
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0 which is available at
6 * https://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 package org.eclipse.jgit.internal.storage.dfs;
12
13 /**
14 * IO statistics for a {@link org.eclipse.jgit.internal.storage.dfs.DfsReader}.
15 */
16 public class DfsReaderIoStats {
17 /** POJO to accumulate IO statistics. */
18 public static class Accumulator {
19 /** Number of times the reader explicitly called scanPacks. */
20 long scanPacks;
21
22 /** Total number of cache hits for pack indexes. */
23 long idxCacheHit;
24
25 /** Total number of cache hits for reverse indexes. */
26 long ridxCacheHit;
27
28 /** Total number of cache hits for bitmap indexes. */
29 long bitmapCacheHit;
30
31 /** Total number of complete pack indexes read into memory. */
32 long readIdx;
33
34 /** Total number of complete bitmap indexes read into memory. */
35 long readBitmap;
36
37 /** Total number of reverse indexes added into memory. */
38 long readReverseIdx;
39
40 /** Total number of bytes read from pack indexes. */
41 long readIdxBytes;
42
43 /** Total microseconds spent reading pack indexes. */
44 long readIdxMicros;
45
46 /** Total microseconds spent creating reverse indexes. */
47 long readReverseIdxMicros;
48
49 /** Total number of bytes read from bitmap indexes. */
50 long readBitmapIdxBytes;
51
52 /** Total microseconds spent reading bitmap indexes. */
53 long readBitmapIdxMicros;
54
55 /** Total number of block cache hits. */
56 long blockCacheHit;
57
58 /**
59 * Total number of discrete blocks actually read from pack file(s), that is,
60 * block cache misses.
61 */
62 long readBlock;
63
64 /**
65 * Total number of compressed bytes read during cache misses, as block sized
66 * units.
67 */
68 long readBlockBytes;
69
70 /** Total microseconds spent reading {@link #readBlock} blocks. */
71 long readBlockMicros;
72
73 /** Total number of bytes decompressed. */
74 long inflatedBytes;
75
76 /** Total microseconds spent inflating compressed bytes. */
77 long inflationMicros;
78
79 Accumulator() {
80 }
81 }
82
83 private final Accumulator stats;
84
85 DfsReaderIoStats(Accumulator stats) {
86 this.stats = stats;
87 }
88
89 /**
90 * Get number of times the reader explicitly called scanPacks.
91 *
92 * @return number of times the reader explicitly called scanPacks.
93 */
94 public long getScanPacks() {
95 return stats.scanPacks;
96 }
97
98 /**
99 * Get total number of pack index cache hits.
100 *
101 * @return total number of pack index cache hits.
102 */
103 public long getPackIndexCacheHits() {
104 return stats.idxCacheHit;
105 }
106
107 /**
108 * Get total number of reverse index cache hits.
109 *
110 * @return total number of reverse index cache hits.
111 */
112 public long getReverseIndexCacheHits() {
113 return stats.ridxCacheHit;
114 }
115
116 /**
117 * Get total number of bitmap index cache hits.
118 *
119 * @return total number of bitmap index cache hits.
120 */
121 public long getBitmapIndexCacheHits() {
122 return stats.bitmapCacheHit;
123 }
124
125 /**
126 * Get total number of complete pack indexes read into memory.
127 *
128 * @return total number of complete pack indexes read into memory.
129 */
130 public long getReadPackIndexCount() {
131 return stats.readIdx;
132 }
133
134 /**
135 * Get total number of times the reverse index was computed.
136 *
137 * @return total number of reverse index was computed.
138 */
139 public long getReadReverseIndexCount() {
140 return stats.readReverseIdx;
141 }
142
143 /**
144 * Get total number of complete bitmap indexes read into memory.
145 *
146 * @return total number of complete bitmap indexes read into memory.
147 */
148 public long getReadBitmapIndexCount() {
149 return stats.readBitmap;
150 }
151
152 /**
153 * Get total number of bytes read from pack indexes.
154 *
155 * @return total number of bytes read from pack indexes.
156 */
157 public long getReadIndexBytes() {
158 return stats.readIdxBytes;
159 }
160
161 /**
162 * Get total microseconds spent reading pack indexes.
163 *
164 * @return total microseconds spent reading pack indexes.
165 */
166 public long getReadIndexMicros() {
167 return stats.readIdxMicros;
168 }
169
170 /**
171 * Get total microseconds spent creating reverse indexes.
172 *
173 * @return total microseconds spent creating reverse indexes.
174 */
175 public long getReadReverseIndexMicros() {
176 return stats.readReverseIdxMicros;
177 }
178
179 /**
180 * Get total number of bytes read from bitmap indexes.
181 *
182 * @return total number of bytes read from bitmap indexes.
183 */
184 public long getReadBitmapIndexBytes() {
185 return stats.readBitmapIdxBytes;
186 }
187
188 /**
189 * Get total microseconds spent reading bitmap indexes.
190 *
191 * @return total microseconds spent reading bitmap indexes.
192 */
193 public long getReadBitmapIndexMicros() {
194 return stats.readBitmapIdxMicros;
195 }
196
197 /**
198 * Get total number of block cache hits.
199 *
200 * @return total number of block cache hits.
201 */
202 public long getBlockCacheHits() {
203 return stats.blockCacheHit;
204 }
205
206 /**
207 * Get total number of discrete blocks actually read from pack file(s), that
208 * is, block cache misses.
209 *
210 * @return total number of discrete blocks read from pack file(s).
211 */
212 public long getReadBlocksCount() {
213 return stats.readBlock;
214 }
215
216 /**
217 * Get total number of compressed bytes read during cache misses, as block
218 * sized units.
219 *
220 * @return total number of compressed bytes read as block sized units.
221 */
222 public long getReadBlocksBytes() {
223 return stats.readBlockBytes;
224 }
225
226 /**
227 * Get total microseconds spent reading blocks during cache misses.
228 *
229 * @return total microseconds spent reading blocks.
230 */
231 public long getReadBlocksMicros() {
232 return stats.readBlockMicros;
233 }
234
235 /**
236 * Get total number of bytes decompressed.
237 *
238 * @return total number of bytes decompressed.
239 */
240 public long getInflatedBytes() {
241 return stats.inflatedBytes;
242 }
243
244 /**
245 * Get total microseconds spent inflating compressed bytes.
246 *
247 * @return total microseconds inflating compressed bytes.
248 */
249 public long getInflationMicros() {
250 return stats.inflationMicros;
251 }
252 }