tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cordz_statistics.h (3451B)


      1 // Copyright 2019 The Abseil Authors.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef ABSL_STRINGS_INTERNAL_CORDZ_STATISTICS_H_
     16 #define ABSL_STRINGS_INTERNAL_CORDZ_STATISTICS_H_
     17 
     18 #include <cstdint>
     19 
     20 #include "absl/base/config.h"
     21 #include "absl/strings/internal/cordz_update_tracker.h"
     22 
     23 namespace absl {
     24 ABSL_NAMESPACE_BEGIN
     25 namespace cord_internal {
     26 
     27 // CordzStatistics captures some meta information about a Cord's shape.
     28 struct CordzStatistics {
     29  using MethodIdentifier = CordzUpdateTracker::MethodIdentifier;
     30 
     31  // Node counts information
     32  struct NodeCounts {
     33    size_t flat = 0;       // #flats
     34    size_t flat_64 = 0;    // #flats up to 64 bytes
     35    size_t flat_128 = 0;   // #flats up to 128 bytes
     36    size_t flat_256 = 0;   // #flats up to 256 bytes
     37    size_t flat_512 = 0;   // #flats up to 512 bytes
     38    size_t flat_1k = 0;    // #flats up to 1K bytes
     39    size_t external = 0;   // #external reps
     40    size_t substring = 0;  // #substring reps
     41    size_t concat = 0;     // #concat reps
     42    size_t ring = 0;       // #ring buffer reps
     43    size_t btree = 0;      // #btree reps
     44    size_t crc = 0;        // #crc reps
     45  };
     46 
     47  // The size of the cord in bytes. This matches the result of Cord::size().
     48  size_t size = 0;
     49 
     50  // The estimated memory used by the sampled cord. This value matches the
     51  // value as reported by Cord::EstimatedMemoryUsage().
     52  // A value of 0 implies the property has not been recorded.
     53  size_t estimated_memory_usage = 0;
     54 
     55  // The effective memory used by the sampled cord, inversely weighted by the
     56  // effective indegree of each allocated node. This is a representation of the
     57  // fair share of memory usage that should be attributed to the sampled cord.
     58  // This value is more useful for cases where one or more nodes are referenced
     59  // by multiple Cord instances, and for cases where a Cord includes the same
     60  // node multiple times (either directly or indirectly).
     61  // A value of 0 implies the property has not been recorded.
     62  size_t estimated_fair_share_memory_usage = 0;
     63 
     64  // The total number of nodes referenced by this cord.
     65  // For ring buffer Cords, this includes the 'ring buffer' node.
     66  // For btree Cords, this includes all 'CordRepBtree' tree nodes as well as all
     67  // the substring, flat and external nodes referenced by the tree.
     68  // A value of 0 implies the property has not been recorded.
     69  size_t node_count = 0;
     70 
     71  // Detailed node counts per type
     72  NodeCounts node_counts;
     73 
     74  // The cord method responsible for sampling the cord.
     75  MethodIdentifier method = MethodIdentifier::kUnknown;
     76 
     77  // The cord method responsible for sampling the parent cord if applicable.
     78  MethodIdentifier parent_method = MethodIdentifier::kUnknown;
     79 
     80  // Update tracker tracking invocation count per cord method.
     81  CordzUpdateTracker update_tracker;
     82 };
     83 
     84 }  // namespace cord_internal
     85 ABSL_NAMESPACE_END
     86 }  // namespace absl
     87 
     88 #endif  // ABSL_STRINGS_INTERNAL_CORDZ_STATISTICS_H_