src/share/vm/gc_implementation/shared/gcOverheadReporter.hpp

Sat, 27 Sep 2008 00:33:13 -0700

author
iveresov
date
Sat, 27 Sep 2008 00:33:13 -0700
changeset 808
06df86c2ec37
parent 777
37f87013dfd8
permissions
-rw-r--r--

6740923: NUMA allocator: Ensure the progress of adaptive chunk resizing
Summary: Treat a chuck where the allocation has failed as fully used.
Reviewed-by: ysr

     1 /*
     2  * Copyright 2001-2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // Keeps track of the GC overhead (both concurrent and STW). It stores
    26 // it in a large array and then prints it to tty at the end of the
    27 // execution.
    29 // See coTracker.hpp for the explanation on what groups are.
    31 // Let's set a maximum number of concurrent overhead groups, to
    32 // statically allocate any arrays we need and not to have to
    33 // malloc/free them. This is just a bit more convenient.
    34 enum {
    35   MaxGCOverheadGroupNum = 4
    36 };
    38 typedef struct {
    39   double _start_sec;
    40   double _end_sec;
    42   double _conc_overhead[MaxGCOverheadGroupNum];
    43   double _stw_overhead;
    44 } GCOverheadReporterEntry;
    46 class GCOverheadReporter {
    47   friend class COReportingThread;
    49 private:
    50   enum PrivateConstants {
    51     DefaultReporterLength = 128 * 1024
    52   };
    54   // Reference to the single instance of this class.
    55   static GCOverheadReporter* _reporter;
    57   // These three references point to the array that contains the GC
    58   // overhead entries (_base is the base of the array, _top is the
    59   // address passed the last entry of the array, _curr is the next
    60   // entry to be used).
    61   GCOverheadReporterEntry* _base;
    62   GCOverheadReporterEntry* _top;
    63   GCOverheadReporterEntry* _curr;
    65   // The number of concurrent overhead groups.
    66   size_t _group_num;
    68   // The wall-clock time of the end of the last recorded period of GC
    69   // overhead.
    70   double _prev_end_sec;
    72   // Names for the concurrent overhead groups.
    73   const char* _group_names[MaxGCOverheadGroupNum];
    75   // Add a new entry to the large array. conc_overhead being NULL is
    76   // equivalent to an array full of 0.0s. conc_overhead should have a
    77   // length of at least _group_num.
    78   void add(double start_sec, double end_sec,
    79            double* conc_overhead,
    80            double stw_overhead);
    82   // Add an entry that represents concurrent GC overhead.
    83   // conc_overhead must be at least of length _group_num.
    84   // conc_overhead being NULL is equivalent to an array full of 0.0s.
    85   void add_conc_overhead(double start_sec, double end_sec,
    86                          double* conc_overhead) {
    87     add(start_sec, end_sec, conc_overhead, 0.0);
    88   }
    90   // Add an entry that represents STW GC overhead.
    91   void add_stw_overhead(double start_sec, double end_sec,
    92                         double stw_overhead) {
    93     add(start_sec, end_sec, NULL, stw_overhead);
    94   }
    96   // It records the start of a STW pause (i.e. it records the
    97   // concurrent overhead up to that point)
    98   void record_stw_start(double start_sec);
   100   // It records the end of a STW pause (i.e. it records the overhead
   101   // associated with the pause and adjusts all the trackers to reflect
   102   // the pause)
   103   void record_stw_end(double end_sec);
   105   // It queries all the trackers of their concurrent overhead and
   106   // records it.
   107   void collect_and_record_conc_overhead(double end_sec);
   109   // It prints the contents of the GC overhead array
   110   void print() const;
   113   // Constructor. The same preconditions for group_num and group_names
   114   // from initGCOverheadReporter apply here too.
   115   GCOverheadReporter(size_t group_num,
   116                      const char* group_names[],
   117                      size_t length = DefaultReporterLength);
   119 public:
   121   // statics
   123   // It initialises the GCOverheadReporter and launches the concurrent
   124   // overhead reporting thread. Both actions happen only if the
   125   // GCOverheadReporting parameter is set. The length of the
   126   // group_names array should be >= group_num and group_num should be
   127   // <= MaxGCOverheadGroupNum. Entries group_namnes[0..group_num-1]
   128   // should not be NULL.
   129   static void initGCOverheadReporter(size_t group_num,
   130                                      const char* group_names[]);
   132   // The following three are provided for convenience and they are
   133   // wrappers around record_stw_start(start_sec), record_stw_end(end_sec),
   134   // and print(). Each of these checks whether GC overhead reporting
   135   // is on (i.e. _reporter != NULL) and, if it is, calls the
   136   // corresponding method. Saves from repeating this pattern again and
   137   // again from the places where they need to be called.
   138   static void recordSTWStart(double start_sec);
   139   static void recordSTWEnd(double end_sec);
   140   static void printGCOverhead();
   141 };

mercurial