1 /* 2 * Copyright (C) 2017, Google Inc. 3 * and other copyright owners as documented in the project's IP log. 4 * 5 * This program and the accompanying materials are made available 6 * under the terms of the Eclipse Distribution License v1.0 which 7 * accompanies this distribution, is reproduced below, and is 8 * available at http://www.eclipse.org/org/documents/edl-v10.php 9 * 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 19 * - Redistributions in binary form must reproduce the above 20 * copyright notice, this list of conditions and the following 21 * disclaimer in the documentation and/or other materials provided 22 * with the distribution. 23 * 24 * - Neither the name of the Eclipse Foundation, Inc. nor the 25 * names of its contributors may be used to endorse or promote 26 * products derived from this software without specific prior 27 * written permission. 28 * 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 30 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 31 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 32 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 34 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 */ 43 44 package org.eclipse.jgit.internal.storage.dfs; 45 46 /** 47 * IO statistics for a {@link org.eclipse.jgit.internal.storage.dfs.DfsReader}. 48 */ 49 public class DfsReaderIoStats { 50 /** POJO to accumulate IO statistics. */ 51 public static class Accumulator { 52 /** Number of times the reader explicitly called scanPacks. */ 53 long scanPacks; 54 55 /** Total number of complete pack indexes read into memory. */ 56 long readIdx; 57 58 /** Total number of complete bitmap indexes read into memory. */ 59 long readBitmap; 60 61 /** Total number of bytes read from indexes. */ 62 long readIdxBytes; 63 64 /** Total microseconds spent reading pack or bitmap indexes. */ 65 long readIdxMicros; 66 67 /** Total number of block cache hits. */ 68 long blockCacheHit; 69 70 /** 71 * Total number of discrete blocks actually read from pack file(s), that is, 72 * block cache misses. 73 */ 74 long readBlock; 75 76 /** 77 * Total number of compressed bytes read during cache misses, as block sized 78 * units. 79 */ 80 long readBlockBytes; 81 82 /** Total microseconds spent reading {@link #readBlock} blocks. */ 83 long readBlockMicros; 84 85 /** Total number of bytes decompressed. */ 86 long inflatedBytes; 87 88 /** Total microseconds spent inflating compressed bytes. */ 89 long inflationMicros; 90 91 Accumulator() { 92 } 93 } 94 95 private final Accumulator stats; 96 97 DfsReaderIoStats(Accumulator stats) { 98 this.stats = stats; 99 } 100 101 /** 102 * Get number of times the reader explicitly called scanPacks. 103 * 104 * @return number of times the reader explicitly called scanPacks. 105 */ 106 public long getScanPacks() { 107 return stats.scanPacks; 108 } 109 110 /** 111 * Get total number of complete pack indexes read into memory. 112 * 113 * @return total number of complete pack indexes read into memory. 114 */ 115 public long getReadPackIndexCount() { 116 return stats.readIdx; 117 } 118 119 /** 120 * Get total number of complete bitmap indexes read into memory. 121 * 122 * @return total number of complete bitmap indexes read into memory. 123 */ 124 public long getReadBitmapIndexCount() { 125 return stats.readBitmap; 126 } 127 128 /** 129 * Get total number of bytes read from indexes. 130 * 131 * @return total number of bytes read from indexes. 132 */ 133 public long getReadIndexBytes() { 134 return stats.readIdxBytes; 135 } 136 137 /** 138 * Get total microseconds spent reading pack or bitmap indexes. 139 * 140 * @return total microseconds spent reading pack or bitmap indexes. 141 */ 142 public long getReadIndexMicros() { 143 return stats.readIdxMicros; 144 } 145 146 /** 147 * Get total number of block cache hits. 148 * 149 * @return total number of block cache hits. 150 */ 151 public long getBlockCacheHits() { 152 return stats.blockCacheHit; 153 } 154 155 /** 156 * Get total number of discrete blocks actually read from pack file(s), that 157 * is, block cache misses. 158 * 159 * @return total number of discrete blocks read from pack file(s). 160 */ 161 public long getReadBlocksCount() { 162 return stats.readBlock; 163 } 164 165 /** 166 * Get total number of compressed bytes read during cache misses, as block 167 * sized units. 168 * 169 * @return total number of compressed bytes read as block sized units. 170 */ 171 public long getReadBlocksBytes() { 172 return stats.readBlockBytes; 173 } 174 175 /** 176 * Get total microseconds spent reading blocks during cache misses. 177 * 178 * @return total microseconds spent reading blocks. 179 */ 180 public long getReadBlocksMicros() { 181 return stats.readBlockMicros; 182 } 183 184 /** 185 * Get total number of bytes decompressed. 186 * 187 * @return total number of bytes decompressed. 188 */ 189 public long getInflatedBytes() { 190 return stats.inflatedBytes; 191 } 192 193 /** 194 * Get total microseconds spent inflating compressed bytes. 195 * 196 * @return total microseconds inflating compressed bytes. 197 */ 198 public long getInflationMicros() { 199 return stats.inflationMicros; 200 } 201 }