src/hotspot/share/gc/z/zStat.cpp
changeset 59148 877c000fd688
parent 58709 662d9e1e2a60
child 59249 29b0d0b61615
equal deleted inserted replaced
59147:e735301d76b9 59148:877c000fd688
  1022 };
  1022 };
  1023 
  1023 
  1024 //
  1024 //
  1025 // Stat cycle
  1025 // Stat cycle
  1026 //
  1026 //
  1027 uint64_t  ZStatCycle::_ncycles = 0;
  1027 uint64_t  ZStatCycle::_nwarmup_cycles = 0;
  1028 Ticks     ZStatCycle::_start_of_last;
  1028 Ticks     ZStatCycle::_start_of_last;
  1029 Ticks     ZStatCycle::_end_of_last;
  1029 Ticks     ZStatCycle::_end_of_last;
  1030 NumberSeq ZStatCycle::_normalized_duration(0.3 /* alpha */);
  1030 NumberSeq ZStatCycle::_normalized_duration(0.3 /* alpha */);
  1031 
  1031 
  1032 void ZStatCycle::at_start() {
  1032 void ZStatCycle::at_start() {
  1033   _start_of_last = Ticks::now();
  1033   _start_of_last = Ticks::now();
  1034 }
  1034 }
  1035 
  1035 
  1036 void ZStatCycle::at_end(double boost_factor) {
  1036 void ZStatCycle::at_end(GCCause::Cause cause, double boost_factor) {
  1037   _end_of_last = Ticks::now();
  1037   _end_of_last = Ticks::now();
  1038   _ncycles++;
  1038 
       
  1039   if (cause == GCCause::_z_warmup) {
       
  1040     _nwarmup_cycles++;
       
  1041   }
  1039 
  1042 
  1040   // Calculate normalized cycle duration. The measured duration is
  1043   // Calculate normalized cycle duration. The measured duration is
  1041   // normalized using the boost factor to avoid artificial deflation
  1044   // normalized using the boost factor to avoid artificial deflation
  1042   // of the duration when boost mode is enabled.
  1045   // of the duration when boost mode is enabled.
  1043   const double duration = (_end_of_last - _start_of_last).seconds();
  1046   const double duration = (_end_of_last - _start_of_last).seconds();
  1044   const double normalized_duration = duration * boost_factor;
  1047   const double normalized_duration = duration * boost_factor;
  1045   _normalized_duration.add(normalized_duration);
  1048   _normalized_duration.add(normalized_duration);
  1046 }
  1049 }
  1047 
  1050 
  1048 bool ZStatCycle::is_first() {
       
  1049   return _ncycles == 0;
       
  1050 }
       
  1051 
       
  1052 bool ZStatCycle::is_warm() {
  1051 bool ZStatCycle::is_warm() {
  1053   return _ncycles >= 3;
  1052   return _nwarmup_cycles >= 3;
  1054 }
  1053 }
  1055 
  1054 
  1056 uint64_t ZStatCycle::ncycles() {
  1055 uint64_t ZStatCycle::nwarmup_cycles() {
  1057   return _ncycles;
  1056   return _nwarmup_cycles;
       
  1057 }
       
  1058 
       
  1059 bool ZStatCycle::is_normalized_duration_trustable() {
       
  1060   // The normalized duration is considered trustable if we have
       
  1061   // completed at least one warmup cycle
       
  1062   return _nwarmup_cycles > 0;
  1058 }
  1063 }
  1059 
  1064 
  1060 const AbsSeq& ZStatCycle::normalized_duration() {
  1065 const AbsSeq& ZStatCycle::normalized_duration() {
  1061   return _normalized_duration;
  1066   return _normalized_duration;
  1062 }
  1067 }
  1063 
  1068 
  1064 double ZStatCycle::time_since_last() {
  1069 double ZStatCycle::time_since_last() {
  1065   if (_ncycles == 0) {
  1070   if (_end_of_last.value() == 0) {
  1066     // Return time since VM start-up
  1071     // No end recorded yet, return time since VM start
  1067     return os::elapsedTime();
  1072     return os::elapsedTime();
  1068   }
  1073   }
  1069 
  1074 
  1070   const Ticks now = Ticks::now();
  1075   const Ticks now = Ticks::now();
  1071   const Tickspan time_since_last = now - _end_of_last;
  1076   const Tickspan time_since_last = now - _end_of_last;