Mercurial > hg > truffle
annotate src/share/vm/utilities/numberSeq.hpp @ 6862:8a5ea0a9ccc4
7127708: G1: change task num types from int to uint in concurrent mark
Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich.
Reviewed-by: johnc
Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author | johnc |
---|---|
date | Sat, 06 Oct 2012 01:17:44 -0700 |
parents | d2a62e0f25eb |
children |
rev | line source |
---|---|
342 | 1 /* |
5938 | 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
342 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1086
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1086
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1086
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_UTILITIES_NUMBERSEQ_HPP |
26 #define SHARE_VM_UTILITIES_NUMBERSEQ_HPP | |
27 | |
6197 | 28 #include "memory/allocation.hpp" |
29 | |
342 | 30 /** |
31 ** This file contains a few classes that represent number sequence, | |
32 ** x1, x2, x3, ..., xN, and can calculate their avg, max, and sd. | |
33 ** | |
34 ** Here's a quick description of the classes: | |
35 ** | |
36 ** AbsSeq: abstract superclass | |
37 ** NumberSeq: the sequence is assumed to be very long and the | |
38 ** maximum, avg, sd, davg, and dsd are calculated over all its elements | |
39 ** TruncatedSeq: this class keeps track of the last L elements | |
40 ** of the sequence and calculates avg, max, and sd only over them | |
41 **/ | |
42 | |
43 #define DEFAULT_ALPHA_VALUE 0.7 | |
44 | |
6197 | 45 class AbsSeq: public CHeapObj<mtInternal> { |
342 | 46 private: |
47 void init(double alpha); | |
48 | |
49 protected: | |
50 int _num; // the number of elements in the sequence | |
51 double _sum; // the sum of the elements in the sequence | |
52 double _sum_of_squares; // the sum of squares of the elements in the sequence | |
53 | |
54 double _davg; // decaying average | |
55 double _dvariance; // decaying variance | |
56 double _alpha; // factor for the decaying average / variance | |
57 | |
58 // This is what we divide with to get the average. In a standard | |
59 // number sequence, this should just be the number of elements in it. | |
60 virtual double total() const { return (double) _num; }; | |
61 | |
62 public: | |
63 AbsSeq(double alpha = DEFAULT_ALPHA_VALUE); | |
64 | |
65 virtual void add(double val); // adds a new element to the sequence | |
66 void add(unsigned val) { add((double) val); } | |
67 virtual double maximum() const = 0; // maximum element in the sequence | |
68 virtual double last() const = 0; // last element added in the sequence | |
69 | |
70 // the number of elements in the sequence | |
71 int num() const { return _num; } | |
72 // the sum of the elements in the sequence | |
73 double sum() const { return _sum; } | |
74 | |
75 double avg() const; // the average of the sequence | |
76 double variance() const; // the variance of the sequence | |
77 double sd() const; // the standard deviation of the sequence | |
78 | |
79 double davg() const; // decaying average | |
80 double dvariance() const; // decaying variance | |
81 double dsd() const; // decaying "standard deviation" | |
1086
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
82 |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
83 // Debugging/Printing |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
84 virtual void dump(); |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
85 virtual void dump_on(outputStream* s); |
342 | 86 }; |
87 | |
88 class NumberSeq: public AbsSeq { | |
89 private: | |
90 bool check_nums(NumberSeq* total, int n, NumberSeq** parts); | |
91 | |
92 protected: | |
93 double _last; | |
94 double _maximum; // keep track of maximum value | |
95 | |
96 public: | |
97 NumberSeq(double alpha = DEFAULT_ALPHA_VALUE); | |
98 | |
99 virtual void add(double val); | |
100 virtual double maximum() const { return _maximum; } | |
101 virtual double last() const { return _last; } | |
1086
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
102 |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
103 // Debugging/Printing |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
104 virtual void dump_on(outputStream* s); |
342 | 105 }; |
106 | |
107 class TruncatedSeq: public AbsSeq { | |
108 private: | |
109 enum PrivateConstants { | |
110 DefaultSeqLength = 10 | |
111 }; | |
112 void init(); | |
113 protected: | |
114 double *_sequence; // buffers the last L elements in the sequence | |
115 int _length; // this is L | |
116 int _next; // oldest slot in the array, i.e. next to be overwritten | |
117 | |
118 public: | |
119 // accepts a value for L | |
120 TruncatedSeq(int length = DefaultSeqLength, | |
121 double alpha = DEFAULT_ALPHA_VALUE); | |
5938 | 122 ~TruncatedSeq(); |
342 | 123 virtual void add(double val); |
124 virtual double maximum() const; | |
125 virtual double last() const; // the last value added to the sequence | |
126 | |
127 double oldest() const; // the oldest valid value in the sequence | |
128 double predict_next() const; // prediction based on linear regression | |
1086
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
129 |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
130 // Debugging/Printing |
89f1b9ae8991
6898948: G1: forensic instrumentation for out-of-bounds recent_avg_pause_time_ratio()
ysr
parents:
342
diff
changeset
|
131 virtual void dump_on(outputStream* s); |
342 | 132 }; |
1972 | 133 |
134 #endif // SHARE_VM_UTILITIES_NUMBERSEQ_HPP |