This file is indexed.

/usr/include/hphp/util/boot-stats.h is in hhvm-dev 3.21.0+dfsg-2ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
/*
   +----------------------------------------------------------------------+
   | HipHop for PHP                                                       |
   +----------------------------------------------------------------------+
   | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com)  |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.php.net/license/3_01.txt                                  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
*/

#pragma once

#include <chrono>
#include <cstdint>
#include <map>
#include <memory>
#include <mutex>
#include <string>

#include <folly/Memory.h>

#include "hphp/util/compatibility.h"

namespace HPHP {
///////////////////////////////////////////////////////////////////////////////

struct ResourceUsage {
  ResourceUsage() : m_wall{0}, m_cpu{0}, m_rssMb(0) {}
  // Returns total usage for entire process.
  static ResourceUsage sinceEpoch();

  void operator=(const ResourceUsage& rhs);
  ResourceUsage operator-(const ResourceUsage& rhs) const;
  ResourceUsage operator+(const ResourceUsage& rhs) const;

  using TimeUnit = std::chrono::nanoseconds;
  TimeUnit wall() const { return m_wall; }
  TimeUnit cpu() const { return m_cpu; }
  int64_t rssMb() const { return m_rssMb; }
  std::string toString() const;

private:
  ResourceUsage(TimeUnit wall, TimeUnit cpu, int64_t rssMb)
      : m_wall{wall}, m_cpu{cpu}, m_rssMb(rssMb) {}
  TimeUnit m_wall;
  TimeUnit m_cpu;
  int64_t m_rssMb;
};

/**
 * Measures execution of the different parts of HHVM startup and warmup.
 *
 * BootStats should be initialized once, soon after HHVM starts up, by calling
 * the start() static method; it will continue collecting samples until the
 * done() static method is called, once the start up process is complete.
 *
 * There are two ways of adding a sample:
 * - BootStats::mark('foo') adds a sample for foo, using the elapsed time from
 *   start or from the last call to mark();
 * - using an instance of the BootStats::Block class during startup
 *   automatically collects a sample.
 */
struct BootStats {
  // Creates a new instance and starts the timer
  static void start();
  // Returns seconds since epoch when start() was called, or 0 if never called.
  static int64_t startTimestamp() {
    auto s = std::chrono::duration_cast<std::chrono::seconds>(s_start.wall());
    return s.count();
  }
  // Stops the timer and logs information
  static void done();
  // Computes the time elapsed from start or from the previous call to this
  // method and stores it as a sample with the given name
  static void mark(const std::string& name);

  struct Block {
    explicit Block(const std::string& name);
    ~Block();

  private:
    std::string m_name;
    ResourceUsage m_start;
  };

private:
  static void add(const std::string& name, const ResourceUsage value);

  struct Impl;

  static bool s_started;
  static ResourceUsage s_start;
  static std::unique_ptr<BootStats::Impl> s_instance;
};

///////////////////////////////////////////////////////////////////////////////
}