DfsReaderIoStats.java

  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. package org.eclipse.jgit.internal.storage.dfs;

  11. /**
  12.  * IO statistics for a {@link org.eclipse.jgit.internal.storage.dfs.DfsReader}.
  13.  */
  14. public class DfsReaderIoStats {
  15.     /** POJO to accumulate IO statistics. */
  16.     public static class Accumulator {
  17.         /** Number of times the reader explicitly called scanPacks. */
  18.         long scanPacks;

  19.         /** Total number of cache hits for pack indexes. */
  20.         long idxCacheHit;

  21.         /** Total number of cache hits for reverse indexes. */
  22.         long ridxCacheHit;

  23.         /** Total number of cache hits for bitmap indexes. */
  24.         long bitmapCacheHit;

  25.         /** Total number of complete pack indexes read into memory. */
  26.         long readIdx;

  27.         /** Total number of complete bitmap indexes read into memory. */
  28.         long readBitmap;

  29.         /** Total number of reverse indexes added into memory. */
  30.         long readReverseIdx;

  31.         /** Total number of bytes read from pack indexes. */
  32.         long readIdxBytes;

  33.         /** Total microseconds spent reading pack indexes. */
  34.         long readIdxMicros;

  35.         /** Total microseconds spent creating reverse indexes. */
  36.         long readReverseIdxMicros;

  37.         /** Total number of bytes read from bitmap indexes. */
  38.         long readBitmapIdxBytes;

  39.         /** Total microseconds spent reading bitmap indexes. */
  40.         long readBitmapIdxMicros;

  41.         /** Total number of block cache hits. */
  42.         long blockCacheHit;

  43.         /**
  44.          * Total number of discrete blocks actually read from pack file(s), that is,
  45.          * block cache misses.
  46.          */
  47.         long readBlock;

  48.         /**
  49.          * Total number of compressed bytes read during cache misses, as block sized
  50.          * units.
  51.          */
  52.         long readBlockBytes;

  53.         /** Total microseconds spent reading {@link #readBlock} blocks. */
  54.         long readBlockMicros;

  55.         /** Total number of bytes decompressed. */
  56.         long inflatedBytes;

  57.         /** Total microseconds spent inflating compressed bytes. */
  58.         long inflationMicros;

  59.         Accumulator() {
  60.         }
  61.     }

  62.     private final Accumulator stats;

  63.     DfsReaderIoStats(Accumulator stats) {
  64.         this.stats = stats;
  65.     }

  66.     /**
  67.      * Get number of times the reader explicitly called scanPacks.
  68.      *
  69.      * @return number of times the reader explicitly called scanPacks.
  70.      */
  71.     public long getScanPacks() {
  72.         return stats.scanPacks;
  73.     }

  74.     /**
  75.      * Get total number of pack index cache hits.
  76.      *
  77.      * @return total number of pack index cache hits.
  78.      */
  79.     public long getPackIndexCacheHits() {
  80.         return stats.idxCacheHit;
  81.     }

  82.     /**
  83.      * Get total number of reverse index cache hits.
  84.      *
  85.      * @return total number of reverse index cache hits.
  86.      */
  87.     public long getReverseIndexCacheHits() {
  88.         return stats.ridxCacheHit;
  89.     }

  90.     /**
  91.      * Get total number of bitmap index cache hits.
  92.      *
  93.      * @return total number of bitmap index cache hits.
  94.      */
  95.     public long getBitmapIndexCacheHits() {
  96.         return stats.bitmapCacheHit;
  97.     }

  98.     /**
  99.      * Get total number of complete pack indexes read into memory.
  100.      *
  101.      * @return total number of complete pack indexes read into memory.
  102.      */
  103.     public long getReadPackIndexCount() {
  104.         return stats.readIdx;
  105.     }

  106.     /**
  107.      * Get total number of times the reverse index was computed.
  108.      *
  109.      * @return total number of reverse index was computed.
  110.      */
  111.     public long getReadReverseIndexCount() {
  112.         return stats.readReverseIdx;
  113.     }

  114.     /**
  115.      * Get total number of complete bitmap indexes read into memory.
  116.      *
  117.      * @return total number of complete bitmap indexes read into memory.
  118.      */
  119.     public long getReadBitmapIndexCount() {
  120.         return stats.readBitmap;
  121.     }

  122.     /**
  123.      * Get total number of bytes read from pack indexes.
  124.      *
  125.      * @return total number of bytes read from pack indexes.
  126.      */
  127.     public long getReadIndexBytes() {
  128.         return stats.readIdxBytes;
  129.     }

  130.     /**
  131.      * Get total microseconds spent reading pack indexes.
  132.      *
  133.      * @return total microseconds spent reading pack indexes.
  134.      */
  135.     public long getReadIndexMicros() {
  136.         return stats.readIdxMicros;
  137.     }

  138.     /**
  139.      * Get total microseconds spent creating reverse indexes.
  140.      *
  141.      * @return total microseconds spent creating reverse indexes.
  142.      */
  143.     public long getReadReverseIndexMicros() {
  144.         return stats.readReverseIdxMicros;
  145.     }

  146.     /**
  147.      * Get total number of bytes read from bitmap indexes.
  148.      *
  149.      * @return total number of bytes read from bitmap indexes.
  150.      */
  151.     public long getReadBitmapIndexBytes() {
  152.         return stats.readBitmapIdxBytes;
  153.     }

  154.     /**
  155.      * Get total microseconds spent reading bitmap indexes.
  156.      *
  157.      * @return total microseconds spent reading bitmap indexes.
  158.      */
  159.     public long getReadBitmapIndexMicros() {
  160.         return stats.readBitmapIdxMicros;
  161.     }

  162.     /**
  163.      * Get total number of block cache hits.
  164.      *
  165.      * @return total number of block cache hits.
  166.      */
  167.     public long getBlockCacheHits() {
  168.         return stats.blockCacheHit;
  169.     }

  170.     /**
  171.      * Get total number of discrete blocks actually read from pack file(s), that
  172.      * is, block cache misses.
  173.      *
  174.      * @return total number of discrete blocks read from pack file(s).
  175.      */
  176.     public long getReadBlocksCount() {
  177.         return stats.readBlock;
  178.     }

  179.     /**
  180.      * Get total number of compressed bytes read during cache misses, as block
  181.      * sized units.
  182.      *
  183.      * @return total number of compressed bytes read as block sized units.
  184.      */
  185.     public long getReadBlocksBytes() {
  186.         return stats.readBlockBytes;
  187.     }

  188.     /**
  189.      * Get total microseconds spent reading blocks during cache misses.
  190.      *
  191.      * @return total microseconds spent reading blocks.
  192.      */
  193.     public long getReadBlocksMicros() {
  194.         return stats.readBlockMicros;
  195.     }

  196.     /**
  197.      * Get total number of bytes decompressed.
  198.      *
  199.      * @return total number of bytes decompressed.
  200.      */
  201.     public long getInflatedBytes() {
  202.         return stats.inflatedBytes;
  203.     }

  204.     /**
  205.      * Get total microseconds spent inflating compressed bytes.
  206.      *
  207.      * @return total microseconds inflating compressed bytes.
  208.      */
  209.     public long getInflationMicros() {
  210.         return stats.inflationMicros;
  211.     }
  212. }