< prev index next >

src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp

8196341: Add JFR events for parallel phases of G1

9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                   
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                   
11  * version 2 for more details (a copy is included in the LICENSE file that                                                 
12  * accompanied this code).                                                                                                 
13  *                                                                                                                         
14  * You should have received a copy of the GNU General Public License version                                               
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                  
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                           
17  *                                                                                                                         
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                 
19  * or visit www.oracle.com if you need additional information or have any                                                  
20  * questions.                                                                                                              
21  *                                                                                                                         
22  */                                                                                                                        
23 
24 #ifndef SHARE_VM_GC_G1_G1GCPHASETIMES_HPP                                                                                  
25 #define SHARE_VM_GC_G1_G1GCPHASETIMES_HPP                                                                                  
26 
27 #include "gc/shared/referenceProcessorPhaseTimes.hpp"                                                                      
28 #include "gc/shared/weakProcessorPhaseTimes.hpp"                                                                           
                                                                                                                           
29 #include "logging/logLevel.hpp"                                                                                            
30 #include "memory/allocation.hpp"                                                                                           
31 #include "utilities/macros.hpp"                                                                                            
32 
33 class LineBuffer;                                                                                                          
34 class G1ParScanThreadState;                                                                                                
35 class STWGCTimer;                                                                                                          
36 
37 template <class T> class WorkerDataArray;                                                                                  
38 
39 class G1GCPhaseTimes : public CHeapObj<mtGC> {                                                                             
40   uint _max_gc_threads;                                                                                                    
41   jlong _gc_start_counter;                                                                                                 
42   double _gc_pause_time_ms;                                                                                                
43 
44  public:                                                                                                                   
45   enum GCParPhases {                                                                                                       
46     GCWorkerStart,                                                                                                         
47     ExtRootScan,                                                                                                           

9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_VM_GC_G1_G1GCPHASETIMES_HPP
25 #define SHARE_VM_GC_G1_G1GCPHASETIMES_HPP
26 
27 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
28 #include "gc/shared/weakProcessorPhaseTimes.hpp"
29 #include "jfr/jfrEvents.hpp"
30 #include "logging/logLevel.hpp"
31 #include "memory/allocation.hpp"
32 #include "utilities/macros.hpp"
33 
34 class LineBuffer;
35 class G1ParScanThreadState;
36 class STWGCTimer;
37 
38 template <class T> class WorkerDataArray;
39 
40 class G1GCPhaseTimes : public CHeapObj<mtGC> {
41   uint _max_gc_threads;
42   jlong _gc_start_counter;
43   double _gc_pause_time_ms;
44 
45  public:
46   enum GCParPhases {
47     GCWorkerStart,
48     ExtRootScan,

172   void log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) const;                    
173   void debug_phase(WorkerDataArray<double>* phase) const;                                                                  
174   void trace_phase(WorkerDataArray<double>* phase, bool print_sum = true) const;                                           
175 
176   void info_time(const char* name, double value) const;                                                                    
177   void debug_time(const char* name, double value) const;                                                                   
178   // This will print logs for both 'gc+phases' and 'gc+phases+ref'.                                                        
179   void debug_time_for_reference(const char* name, double value) const;                                                     
180   void trace_time(const char* name, double value) const;                                                                   
181   void trace_count(const char* name, size_t value) const;                                                                  
182 
183   double print_pre_evacuate_collection_set() const;                                                                        
184   double print_evacuate_collection_set() const;                                                                            
185   double print_post_evacuate_collection_set() const;                                                                       
186   void print_other(double accounted_ms) const;                                                                             
187 
188  public:                                                                                                                   
189   G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads);                                                               
190   void note_gc_start();                                                                                                    
191   void print();                                                                                                            
                                                                                                                           
192 
193   // record the time a phase took in seconds                                                                               
194   void record_time_secs(GCParPhases phase, uint worker_i, double secs);                                                    
195 
196   // add a number of seconds to a phase                                                                                    
197   void add_time_secs(GCParPhases phase, uint worker_i, double secs);                                                       
198 
199   void record_or_add_objcopy_time_secs(uint worker_i, double secs);                                                        
200 
201   void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index = 0);                            
202 
203   // return the average time for a phase in milliseconds                                                                   
204   double average_time_ms(GCParPhases phase);                                                                               
205 
206   size_t sum_thread_work_items(GCParPhases phase, uint index = 0);                                                         
207 
208  public:                                                                                                                   
209 
210   void record_prepare_tlab_time_ms(double ms) {                                                                            

173   void log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) const;
174   void debug_phase(WorkerDataArray<double>* phase) const;
175   void trace_phase(WorkerDataArray<double>* phase, bool print_sum = true) const;
176 
177   void info_time(const char* name, double value) const;
178   void debug_time(const char* name, double value) const;
179   // This will print logs for both 'gc+phases' and 'gc+phases+ref'.
180   void debug_time_for_reference(const char* name, double value) const;
181   void trace_time(const char* name, double value) const;
182   void trace_count(const char* name, size_t value) const;
183 
184   double print_pre_evacuate_collection_set() const;
185   double print_evacuate_collection_set() const;
186   double print_post_evacuate_collection_set() const;
187   void print_other(double accounted_ms) const;
188 
189  public:
190   G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads);
191   void note_gc_start();
192   void print();
193   static const char* phase_name(GCParPhases phase);
194 
195   // record the time a phase took in seconds
196   void record_time_secs(GCParPhases phase, uint worker_i, double secs);
197 
198   // add a number of seconds to a phase
199   void add_time_secs(GCParPhases phase, uint worker_i, double secs);
200 
201   void record_or_add_objcopy_time_secs(uint worker_i, double secs);
202 
203   void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index = 0);
204 
205   // return the average time for a phase in milliseconds
206   double average_time_ms(GCParPhases phase);
207 
208   size_t sum_thread_work_items(GCParPhases phase, uint index = 0);
209 
210  public:
211 
212   void record_prepare_tlab_time_ms(double ms) {

367   G1ParScanThreadState* _pss;                                                                                              
368   Ticks _start;                                                                                                            
369 
370   Tickspan& _total_time;                                                                                                   
371   Tickspan& _trim_time;                                                                                                    
372 
373   bool _stopped;                                                                                                           
374 public:                                                                                                                    
375   G1EvacPhaseWithTrimTimeTracker(G1ParScanThreadState* pss, Tickspan& total_time, Tickspan& trim_time);                    
376   ~G1EvacPhaseWithTrimTimeTracker();                                                                                       
377 
378   void stop();                                                                                                             
379 };                                                                                                                         
380 
381 class G1GCParPhaseTimesTracker : public CHeapObj<mtGC> {                                                                   
382 protected:                                                                                                                 
383   Ticks _start_time;                                                                                                       
384   G1GCPhaseTimes::GCParPhases _phase;                                                                                      
385   G1GCPhaseTimes* _phase_times;                                                                                            
386   uint _worker_id;                                                                                                         
                                                                                                                           
387 public:                                                                                                                    
388   G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id);                
389   virtual ~G1GCParPhaseTimesTracker();                                                                                     
390 };                                                                                                                         
391 
392 class G1EvacPhaseTimesTracker : public G1GCParPhaseTimesTracker {                                                          
393   Tickspan _total_time;                                                                                                    
394   Tickspan _trim_time;                                                                                                     
395 
396   G1EvacPhaseWithTrimTimeTracker _trim_tracker;                                                                            
397 public:                                                                                                                    
398   G1EvacPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1ParScanThreadState* pss, G1GCPhaseTimes::GCParPhases phase, uint w
399   virtual ~G1EvacPhaseTimesTracker();                                                                                      
400 };                                                                                                                         
401 
402 #endif // SHARE_VM_GC_G1_G1GCPHASETIMES_HPP                                                                                

369   G1ParScanThreadState* _pss;
370   Ticks _start;
371 
372   Tickspan& _total_time;
373   Tickspan& _trim_time;
374 
375   bool _stopped;
376 public:
377   G1EvacPhaseWithTrimTimeTracker(G1ParScanThreadState* pss, Tickspan& total_time, Tickspan& trim_time);
378   ~G1EvacPhaseWithTrimTimeTracker();
379 
380   void stop();
381 };
382 
383 class G1GCParPhaseTimesTracker : public CHeapObj<mtGC> {
384 protected:
385   Ticks _start_time;
386   G1GCPhaseTimes::GCParPhases _phase;
387   G1GCPhaseTimes* _phase_times;
388   uint _worker_id;
389   EventGCPhaseParallel _event;
390 public:
391   G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id);
392   virtual ~G1GCParPhaseTimesTracker();
393 };
394 
395 class G1EvacPhaseTimesTracker : public G1GCParPhaseTimesTracker {
396   Tickspan _total_time;
397   Tickspan _trim_time;
398 
399   G1EvacPhaseWithTrimTimeTracker _trim_tracker;
400 public:
401   G1EvacPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1ParScanThreadState* pss, G1GCPhaseTimes::GCParPhases phase, uint w
402   virtual ~G1EvacPhaseTimesTracker();
403 };
404 
405 #endif // SHARE_VM_GC_G1_G1GCPHASETIMES_HPP
< prev index next >