src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp

Tue, 18 Mar 2014 19:07:22 +0100

author
pliden
date
Tue, 18 Mar 2014 19:07:22 +0100
changeset 6413
595c0f60d50d
parent 6406
eff02b5bd56c
child 6552
8847586c9037
permissions
-rw-r--r--

8029075: String deduplication in G1
Summary: Implementation of JEP 192, http://openjdk.java.net/jeps/192
Reviewed-by: brutisso, tschatzl, coleenp

     1 /*
     2  * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
    28 #include "memory/allocation.hpp"
    29 #include "gc_interface/gcCause.hpp"
    31 template <class T>
    32 class WorkerDataArray  : public CHeapObj<mtGC> {
    33   T*          _data;
    34   uint        _length;
    35   const char* _print_format;
    36   bool        _print_sum;
    38   NOT_PRODUCT(static const T _uninitialized;)
    40   // We are caching the sum and average to only have to calculate them once.
    41   // This is not done in an MT-safe way. It is intended to allow single
    42   // threaded code to call sum() and average() multiple times in any order
    43   // without having to worry about the cost.
    44   bool   _has_new_data;
    45   T      _sum;
    46   double _average;
    48  public:
    49   WorkerDataArray(uint length, const char* print_format, bool print_sum = true) :
    50   _length(length), _print_format(print_format), _print_sum(print_sum), _has_new_data(true) {
    51     assert(length > 0, "Must have some workers to store data for");
    52     _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
    53   }
    55   ~WorkerDataArray() {
    56     FREE_C_HEAP_ARRAY(T, _data, mtGC);
    57   }
    59   void set(uint worker_i, T value) {
    60     assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
    61     assert(_data[worker_i] == (T)-1, err_msg("Overwriting data for worker %d", worker_i));
    62     _data[worker_i] = value;
    63     _has_new_data = true;
    64   }
    66   T get(uint worker_i) {
    67     assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
    68     assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
    69     return _data[worker_i];
    70   }
    72   void add(uint worker_i, T value) {
    73     assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
    74     assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
    75     _data[worker_i] += value;
    76     _has_new_data = true;
    77   }
    79   double average(){
    80     if (_has_new_data) {
    81       calculate_totals();
    82     }
    83     return _average;
    84   }
    86   T sum() {
    87     if (_has_new_data) {
    88       calculate_totals();
    89     }
    90     return _sum;
    91   }
    93   void print(int level, const char* title);
    95   void reset() PRODUCT_RETURN;
    96   void verify() PRODUCT_RETURN;
    98  private:
   100   void calculate_totals(){
   101     _sum = (T)0;
   102     for (uint i = 0; i < _length; ++i) {
   103       _sum += _data[i];
   104     }
   105     _average = (double)_sum / (double)_length;
   106     _has_new_data = false;
   107   }
   108 };
   110 class G1GCPhaseTimes : public CHeapObj<mtGC> {
   112  private:
   113   uint _active_gc_threads;
   114   uint _max_gc_threads;
   116   WorkerDataArray<double> _last_gc_worker_start_times_ms;
   117   WorkerDataArray<double> _last_ext_root_scan_times_ms;
   118   WorkerDataArray<double> _last_satb_filtering_times_ms;
   119   WorkerDataArray<double> _last_update_rs_times_ms;
   120   WorkerDataArray<int>    _last_update_rs_processed_buffers;
   121   WorkerDataArray<double> _last_scan_rs_times_ms;
   122   WorkerDataArray<double> _last_strong_code_root_scan_times_ms;
   123   WorkerDataArray<double> _last_strong_code_root_mark_times_ms;
   124   WorkerDataArray<double> _last_obj_copy_times_ms;
   125   WorkerDataArray<double> _last_termination_times_ms;
   126   WorkerDataArray<size_t> _last_termination_attempts;
   127   WorkerDataArray<double> _last_gc_worker_end_times_ms;
   128   WorkerDataArray<double> _last_gc_worker_times_ms;
   129   WorkerDataArray<double> _last_gc_worker_other_times_ms;
   131   double _cur_collection_par_time_ms;
   132   double _cur_collection_code_root_fixup_time_ms;
   133   double _cur_strong_code_root_migration_time_ms;
   134   double _cur_strong_code_root_purge_time_ms;
   136   double _cur_evac_fail_recalc_used;
   137   double _cur_evac_fail_restore_remsets;
   138   double _cur_evac_fail_remove_self_forwards;
   140   double                  _cur_string_dedup_fixup_time_ms;
   141   WorkerDataArray<double> _cur_string_dedup_queue_fixup_worker_times_ms;
   142   WorkerDataArray<double> _cur_string_dedup_table_fixup_worker_times_ms;
   144   double _cur_clear_ct_time_ms;
   145   double _cur_ref_proc_time_ms;
   146   double _cur_ref_enq_time_ms;
   148   double _cur_collection_start_sec;
   149   double _root_region_scan_wait_time_ms;
   151   double _recorded_young_cset_choice_time_ms;
   152   double _recorded_non_young_cset_choice_time_ms;
   154   double _recorded_redirty_logged_cards_time_ms;
   156   double _recorded_young_free_cset_time_ms;
   157   double _recorded_non_young_free_cset_time_ms;
   159   double _cur_verify_before_time_ms;
   160   double _cur_verify_after_time_ms;
   162   // Helper methods for detailed logging
   163   void print_stats(int level, const char* str, double value);
   164   void print_stats(int level, const char* str, double value, int workers);
   166  public:
   167   G1GCPhaseTimes(uint max_gc_threads);
   168   void note_gc_start(uint active_gc_threads);
   169   void note_gc_end();
   170   void print(double pause_time_sec);
   172   void record_gc_worker_start_time(uint worker_i, double ms) {
   173     _last_gc_worker_start_times_ms.set(worker_i, ms);
   174   }
   176   void record_ext_root_scan_time(uint worker_i, double ms) {
   177     _last_ext_root_scan_times_ms.set(worker_i, ms);
   178   }
   180   void record_satb_filtering_time(uint worker_i, double ms) {
   181     _last_satb_filtering_times_ms.set(worker_i, ms);
   182   }
   184   void record_update_rs_time(uint worker_i, double ms) {
   185     _last_update_rs_times_ms.set(worker_i, ms);
   186   }
   188   void record_update_rs_processed_buffers(uint worker_i, int processed_buffers) {
   189     _last_update_rs_processed_buffers.set(worker_i, processed_buffers);
   190   }
   192   void record_scan_rs_time(uint worker_i, double ms) {
   193     _last_scan_rs_times_ms.set(worker_i, ms);
   194   }
   196   void record_strong_code_root_scan_time(uint worker_i, double ms) {
   197     _last_strong_code_root_scan_times_ms.set(worker_i, ms);
   198   }
   200   void record_strong_code_root_mark_time(uint worker_i, double ms) {
   201     _last_strong_code_root_mark_times_ms.set(worker_i, ms);
   202   }
   204   void record_obj_copy_time(uint worker_i, double ms) {
   205     _last_obj_copy_times_ms.set(worker_i, ms);
   206   }
   208   void add_obj_copy_time(uint worker_i, double ms) {
   209     _last_obj_copy_times_ms.add(worker_i, ms);
   210   }
   212   void record_termination(uint worker_i, double ms, size_t attempts) {
   213     _last_termination_times_ms.set(worker_i, ms);
   214     _last_termination_attempts.set(worker_i, attempts);
   215   }
   217   void record_gc_worker_end_time(uint worker_i, double ms) {
   218     _last_gc_worker_end_times_ms.set(worker_i, ms);
   219   }
   221   void record_clear_ct_time(double ms) {
   222     _cur_clear_ct_time_ms = ms;
   223   }
   225   void record_par_time(double ms) {
   226     _cur_collection_par_time_ms = ms;
   227   }
   229   void record_code_root_fixup_time(double ms) {
   230     _cur_collection_code_root_fixup_time_ms = ms;
   231   }
   233   void record_strong_code_root_migration_time(double ms) {
   234     _cur_strong_code_root_migration_time_ms = ms;
   235   }
   237   void record_strong_code_root_purge_time(double ms) {
   238     _cur_strong_code_root_purge_time_ms = ms;
   239   }
   241   void record_evac_fail_recalc_used_time(double ms) {
   242     _cur_evac_fail_recalc_used = ms;
   243   }
   245   void record_evac_fail_restore_remsets(double ms) {
   246     _cur_evac_fail_restore_remsets = ms;
   247   }
   249   void record_evac_fail_remove_self_forwards(double ms) {
   250     _cur_evac_fail_remove_self_forwards = ms;
   251   }
   253   void note_string_dedup_fixup_start();
   254   void note_string_dedup_fixup_end();
   256   void record_string_dedup_fixup_time(double ms) {
   257     _cur_string_dedup_fixup_time_ms = ms;
   258   }
   260   void record_string_dedup_queue_fixup_worker_time(uint worker_id, double ms) {
   261     _cur_string_dedup_queue_fixup_worker_times_ms.set(worker_id, ms);
   262   }
   264   void record_string_dedup_table_fixup_worker_time(uint worker_id, double ms) {
   265     _cur_string_dedup_table_fixup_worker_times_ms.set(worker_id, ms);
   266   }
   268   void record_ref_proc_time(double ms) {
   269     _cur_ref_proc_time_ms = ms;
   270   }
   272   void record_ref_enq_time(double ms) {
   273     _cur_ref_enq_time_ms = ms;
   274   }
   276   void record_root_region_scan_wait_time(double time_ms) {
   277     _root_region_scan_wait_time_ms = time_ms;
   278   }
   280   void record_young_free_cset_time_ms(double time_ms) {
   281     _recorded_young_free_cset_time_ms = time_ms;
   282   }
   284   void record_non_young_free_cset_time_ms(double time_ms) {
   285     _recorded_non_young_free_cset_time_ms = time_ms;
   286   }
   288   void record_young_cset_choice_time_ms(double time_ms) {
   289     _recorded_young_cset_choice_time_ms = time_ms;
   290   }
   292   void record_non_young_cset_choice_time_ms(double time_ms) {
   293     _recorded_non_young_cset_choice_time_ms = time_ms;
   294   }
   296   void record_redirty_logged_cards_time_ms(double time_ms) {
   297     _recorded_redirty_logged_cards_time_ms = time_ms;
   298   }
   300   void record_cur_collection_start_sec(double time_ms) {
   301     _cur_collection_start_sec = time_ms;
   302   }
   304   void record_verify_before_time_ms(double time_ms) {
   305     _cur_verify_before_time_ms = time_ms;
   306   }
   308   void record_verify_after_time_ms(double time_ms) {
   309     _cur_verify_after_time_ms = time_ms;
   310   }
   312   double accounted_time_ms();
   314   double cur_collection_start_sec() {
   315     return _cur_collection_start_sec;
   316   }
   318   double cur_collection_par_time_ms() {
   319     return _cur_collection_par_time_ms;
   320   }
   322   double cur_clear_ct_time_ms() {
   323     return _cur_clear_ct_time_ms;
   324   }
   326   double root_region_scan_wait_time_ms() {
   327     return _root_region_scan_wait_time_ms;
   328   }
   330   double young_cset_choice_time_ms() {
   331     return _recorded_young_cset_choice_time_ms;
   332   }
   334   double young_free_cset_time_ms() {
   335     return _recorded_young_free_cset_time_ms;
   336   }
   338   double non_young_cset_choice_time_ms() {
   339     return _recorded_non_young_cset_choice_time_ms;
   340   }
   342   double non_young_free_cset_time_ms() {
   343     return _recorded_non_young_free_cset_time_ms;
   344   }
   346   double average_last_update_rs_time() {
   347     return _last_update_rs_times_ms.average();
   348   }
   350   int sum_last_update_rs_processed_buffers() {
   351     return _last_update_rs_processed_buffers.sum();
   352   }
   354   double average_last_scan_rs_time(){
   355     return _last_scan_rs_times_ms.average();
   356   }
   358   double average_last_strong_code_root_scan_time(){
   359     return _last_strong_code_root_scan_times_ms.average();
   360   }
   362   double average_last_strong_code_root_mark_time(){
   363     return _last_strong_code_root_mark_times_ms.average();
   364   }
   366   double average_last_obj_copy_time() {
   367     return _last_obj_copy_times_ms.average();
   368   }
   370   double average_last_termination_time() {
   371     return _last_termination_times_ms.average();
   372   }
   374   double average_last_ext_root_scan_time() {
   375     return _last_ext_root_scan_times_ms.average();
   376   }
   378   double average_last_satb_filtering_times_ms() {
   379     return _last_satb_filtering_times_ms.average();
   380   }
   381 };
   383 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP

mercurial