Blame uds/cacheCounters.h

Packit Service 310c69
/*
Packit Service 310c69
 * Copyright (c) 2020 Red Hat, Inc.
Packit Service 310c69
 *
Packit Service 310c69
 * This program is free software; you can redistribute it and/or
Packit Service 310c69
 * modify it under the terms of the GNU General Public License
Packit Service 310c69
 * as published by the Free Software Foundation; either version 2
Packit Service 310c69
 * of the License, or (at your option) any later version.
Packit Service 310c69
 * 
Packit Service 310c69
 * This program is distributed in the hope that it will be useful,
Packit Service 310c69
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 310c69
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 310c69
 * GNU General Public License for more details.
Packit Service 310c69
 * 
Packit Service 310c69
 * You should have received a copy of the GNU General Public License
Packit Service 310c69
 * along with this program; if not, write to the Free Software
Packit Service 310c69
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 310c69
 * 02110-1301, USA. 
Packit Service 310c69
 *
Packit Service 310c69
 * $Id: //eng/uds-releases/jasper/src/uds/cacheCounters.h#1 $
Packit Service 310c69
 */
Packit Service 310c69
Packit Service 310c69
#ifndef CACHE_COUNTERS_H
Packit Service 310c69
#define CACHE_COUNTERS_H
Packit Service 310c69
Packit Service 310c69
#include "typeDefs.h"
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * Basic counts of hits and misses for a given type of cache probe.
Packit Service 310c69
 **/
Packit Service 310c69
typedef struct cacheCountsByKind {
Packit Service 310c69
  /** Number of hits */
Packit Service 310c69
  uint64_t hits;
Packit Service 310c69
  /** Number of misses */
Packit Service 310c69
  uint64_t misses;
Packit Service 310c69
  /** Number of probes for data already queued for read */
Packit Service 310c69
  uint64_t queued;
Packit Service 310c69
} CacheCountsByKind;
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * The various types of cache probes we care about.
Packit Service 310c69
 **/
Packit Service 310c69
typedef enum cacheProbeType {
Packit Service 310c69
  /** First attempt to look up an index page, for a given request. */
Packit Service 310c69
  CACHE_PROBE_INDEX_FIRST = 0,
Packit Service 310c69
  /** First attempt to look up a record page, for a given request. */
Packit Service 310c69
  CACHE_PROBE_RECORD_FIRST,
Packit Service 310c69
  /** Second or later attempt to look up an index page, for a given request. */
Packit Service 310c69
  CACHE_PROBE_INDEX_RETRY,
Packit Service 310c69
  /** Second or later attempt to look up a record page, for a given request. */
Packit Service 310c69
  CACHE_PROBE_RECORD_RETRY
Packit Service 310c69
} CacheProbeType;
Packit Service 310c69
Packit Service 310c69
enum {
Packit Service 310c69
  /** Flag bit to indicate that failures shouldn't be recorded.  */
Packit Service 310c69
  CACHE_PROBE_IGNORE_FAILURE = 128
Packit Service 310c69
};
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * Result-type counts for both kinds of data pages in the page cache.
Packit Service 310c69
 **/
Packit Service 310c69
typedef struct cacheCountsByPageType {
Packit Service 310c69
  /** His/miss counts for index pages. */
Packit Service 310c69
  CacheCountsByKind indexPage;
Packit Service 310c69
  /** Hit/miss counts for record pages. */
Packit Service 310c69
  CacheCountsByKind recordPage;
Packit Service 310c69
} CacheCountsByPageType;
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * All the counters used for an entry cache.
Packit Service 310c69
 **/
Packit Service 310c69
typedef struct cacheCounters {
Packit Service 310c69
  // counters for the page cache
Packit Service 310c69
  /** Hit/miss counts for the first attempt per request */
Packit Service 310c69
  CacheCountsByPageType firstTime;
Packit Service 310c69
  /** Hit/miss counts when a second (or later) attempt is needed */
Packit Service 310c69
  CacheCountsByPageType retried;
Packit Service 310c69
Packit Service 310c69
  /** Number of cache entry invalidations due to single-entry eviction */
Packit Service 310c69
  uint64_t              evictions;
Packit Service 310c69
  /** Number of cache entry invalidations due to chapter expiration */
Packit Service 310c69
  uint64_t              expirations;
Packit Service 310c69
Packit Service 310c69
  // counters for the sparse chapter index cache
Packit Service 310c69
  /** Hit/miss counts for the sparse cache chapter probes */
Packit Service 310c69
  CacheCountsByKind     sparseChapters;
Packit Service 310c69
  /** Hit/miss counts for the sparce cache name searches */
Packit Service 310c69
  CacheCountsByKind     sparseSearches;
Packit Service 310c69
} CacheCounters;
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * Success/failure assessment of cache probe result.
Packit Service 310c69
 **/
Packit Service 310c69
typedef enum cacheResultKind {
Packit Service 310c69
  /** The requested entry was found in the cache */
Packit Service 310c69
  CACHE_RESULT_HIT,
Packit Service 310c69
  /** The requested entry was not found in the cache */
Packit Service 310c69
  CACHE_RESULT_MISS,
Packit Service 310c69
  /** The requested entry wasn't found in the cache but is queued for read */
Packit Service 310c69
  CACHE_RESULT_QUEUED
Packit Service 310c69
} CacheResultKind;
Packit Service 310c69
Packit Service 310c69
/**
Packit Service 310c69
 * Increment one of the cache counters.
Packit Service 310c69
 *
Packit Service 310c69
 * @param counters    pointer to the counters
Packit Service 310c69
 * @param probeType   type of access done
Packit Service 310c69
 * @param kind        result of probe
Packit Service 310c69
 **/
Packit Service 310c69
void incrementCacheCounter(CacheCounters   *counters,
Packit Service 310c69
                           int              probeType,
Packit Service 310c69
                           CacheResultKind  kind);
Packit Service 310c69
Packit Service 310c69
#endif /* CACHE_COUNTERS_H */