// Copyright 2023 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package memory_pressure;

option java_package = "com.google.devtools.build.lib.runtime";

// Statistics about memory pressure handling.
message MemoryPressureStats {
  // Deprecated: An artifact of RetainedHeapLimiter. GcThrashingDetector (its
  // replacement) does not manually trigger GC.
  int32 manually_triggered_gcs = 1 [deprecated = true];
  // Deprecated: An artifact of RetainedHeapLimiter. GcThrashingDetector (its
  // replacement) does not ignore any non-manual full GC.
  int32 max_consecutive_ignored_gcs_over_threshold = 2 [deprecated = true];
  // Number of times HighWaterMarkLimiter dropped caches after minor GCs.
  int32 minor_gc_drops = 3;
  // Number of times HighWaterMarkLimiter dropped caches after full GCs.
  int32 full_gc_drops = 4;

  // After a full GC, a point-in-time snapshot of the fraction of the
  // invocation's wall time so far that has been spent on full GCs.
  message FullGcFractionPoint {
    // After this many milliseconds into the invocation,
    int32 invocation_wall_time_so_far_ms = 1;

    // This fraction of that wall time has been spent on full GCs.
    double full_gc_fraction_so_far = 2;
  }
  // Chronological history of full GCs in this invocation (i.e. elements are in
  // increasing order of invocation_wall_time_so_far_ms).
  repeated FullGcFractionPoint full_gc_fraction_point = 5;

  // Peak point in full_gc_fraction_point. Precomputed for convenient querying.
  FullGcFractionPoint peak_full_gc_fraction_point = 6;
}
