< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.hpp

Print this page

 1 /*
 2  * Copyright (c) 2018, 2019, Red Hat, 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 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  *

32 // the magnitude of the value being stored, and the second array maintains
33 // the low resolution histogram within that magnitude. For example, storing
34 // 4.352819 * 10^3 increments the bucket _hdr[3][435]. This allows for
35 // memory efficient storage of huge amount of samples.
36 //
37 // Accepts positive numbers only.
38 class HdrSeq: public NumberSeq {
39 private:
40   enum PrivateConstants {
41     ValBuckets = 512,
42     MagBuckets = 24,
43     MagMinimum = -12
44   };
45   int** _hdr;
46 
47 public:
48   HdrSeq();
49   ~HdrSeq();
50 
51   virtual void add(double val);

52   double percentile(double level) const;

53 };
54 
55 // Binary magnitude sequence stores the power-of-two histogram.
56 // It has very low memory requirements, and is thread-safe. When accuracy
57 // is not needed, it is preferred over HdrSeq.
58 class BinaryMagnitudeSeq : public CHeapObj<mtGC> {
59 private:
60   size_t  _sum;
61   size_t* _mags;
62 
63 public:
64   BinaryMagnitudeSeq();
65   ~BinaryMagnitudeSeq();
66 
67   void add(size_t val);
68   size_t num() const;
69   size_t level(int level) const;
70   size_t sum() const;
71   int min_level() const;
72   int max_level() const;

 1 /*
 2  * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
 3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
 4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 5  *
 6  * This code is free software; you can redistribute it and/or modify it
 7  * under the terms of the GNU General Public License version 2 only, as
 8  * published by the Free Software Foundation.
 9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  *

33 // the magnitude of the value being stored, and the second array maintains
34 // the low resolution histogram within that magnitude. For example, storing
35 // 4.352819 * 10^3 increments the bucket _hdr[3][435]. This allows for
36 // memory efficient storage of huge amount of samples.
37 //
38 // Accepts positive numbers only.
39 class HdrSeq: public NumberSeq {
40 private:
41   enum PrivateConstants {
42     ValBuckets = 512,
43     MagBuckets = 24,
44     MagMinimum = -12
45   };
46   int** _hdr;
47 
48 public:
49   HdrSeq();
50   ~HdrSeq();
51 
52   virtual void add(double val);
53   void add(const HdrSeq& other);
54   double percentile(double level) const;
55   void clear();
56 };
57 
58 // Binary magnitude sequence stores the power-of-two histogram.
59 // It has very low memory requirements, and is thread-safe. When accuracy
60 // is not needed, it is preferred over HdrSeq.
61 class BinaryMagnitudeSeq : public CHeapObj<mtGC> {
62 private:
63   size_t  _sum;
64   size_t* _mags;
65 
66 public:
67   BinaryMagnitudeSeq();
68   ~BinaryMagnitudeSeq();
69 
70   void add(size_t val);
71   size_t num() const;
72   size_t level(int level) const;
73   size_t sum() const;
74   int min_level() const;
75   int max_level() const;
< prev index next >