Skip to content

Commit

Permalink
FEAT(gc): rename the class histogram to GCHistogram to prevent errors…
Browse files Browse the repository at this point in the history
… when compiling the slowdebug version.

Fix the bug that slowdebug version failed to compile

--bug=80034743

Contributed-by:wattsun
  • Loading branch information
wattsun110 authored and linzang committed Nov 6, 2020
1 parent f079390 commit 8e9bb73
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion hotspot/src/share/vm/gc_interface/collectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ CollectedHeap::CollectedHeap() : _n_par_threads(0)
_last_minor_gc_time = 0;
// init histogram
if (PeriodicGCInterval > 0) {
_minor_gc_frequency_histogram = new Histogram();
_minor_gc_frequency_histogram = new GCHistogram();
if (NULL == _minor_gc_frequency_histogram) {
// will disable period gc
PeriodicGCInterval = 0;
Expand Down
6 changes: 3 additions & 3 deletions hotspot/src/share/vm/gc_interface/collectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "runtime/safepoint.hpp"
#include "utilities/events.hpp"
#include "utilities/taskqueue.hpp"
#include "services/histogram.hpp"
#include "services/gcHistogram.hpp"

// A "CollectedHeap" is an implementation of a java heap for HotSpot. This
// is an abstract class: there may be many different kinds of heaps. This
Expand Down Expand Up @@ -128,7 +128,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
//_last_minor_gc_time will be changed frequently and need to be visible to 2 threads
volatile size_t _last_minor_gc_time;
//histogram for young gc
Histogram* _minor_gc_frequency_histogram;
GCHistogram* _minor_gc_frequency_histogram;
//last full gc time
//_last_full_gc_time will be changed frequently and need to be visible to 2 threads
volatile double _last_full_gc_time;
Expand Down Expand Up @@ -341,7 +341,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
return _free_heap_memory_task_queue;
}

Histogram* minor_gc_frequency_histogram() {
GCHistogram* minor_gc_frequency_histogram() {
return _minor_gc_frequency_histogram;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "histogram.hpp"
#include "gcHistogram.hpp"
#include <float.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>

int Histogram::binary_search(long key) {
int GCHistogram::binary_search(long key) {
int low = 0, high = ALL_LEVEL, mid = 0;

while (low < high) {
Expand All @@ -41,7 +41,7 @@ int Histogram::binary_search(long key) {
return ((_bucket_limits[mid] <= key) ? low : (ALL_LEVEL - 2));
}

int Histogram::binary_search(long *array, int size, long key) {
int GCHistogram::binary_search(long *array, int size, long key) {
int first = 0, count = size, step;
int it = 0;

Expand All @@ -60,7 +60,7 @@ int Histogram::binary_search(long *array, int size, long key) {
return (0 == first ? first : first -1);
}

int Histogram::search(long key) {
int GCHistogram::search(long key) {
//fast path
int result = (int)(key / 100);
if (result < LEVEL1) {
Expand All @@ -71,9 +71,9 @@ int Histogram::search(long key) {
return binary_search(_bucket_limits, ALL_LEVEL, key);
}

Histogram::Histogram() : _bucket_limits(init_default_buckets()) { clear(); }
GCHistogram::GCHistogram() : _bucket_limits(init_default_buckets()) { clear(); }

long* Histogram::init_default_buckets_inner() {
long* GCHistogram::init_default_buckets_inner() {
long* result = new long[ALL_LEVEL];
for (int i = 0; i < ALL_LEVEL; i++) {
if (i < LEVEL1) {//100,200,300......19000
Expand All @@ -90,19 +90,19 @@ long* Histogram::init_default_buckets_inner() {
return result;
}

long* Histogram::init_default_buckets() {
long* GCHistogram::init_default_buckets() {
long* default_bucket_limits = init_default_buckets_inner();
return default_bucket_limits;
}

// Create a histogram with a custom set of bucket limits,
Histogram::Histogram(long* custom_bucket_limits)
GCHistogram::GCHistogram(long* custom_bucket_limits)
: _custom_bucket_limits(custom_bucket_limits),
_bucket_limits(_custom_bucket_limits) {
clear();
}

void Histogram::clear() {
void GCHistogram::clear() {
_min = _bucket_limits[ALL_LEVEL - 1];
_max = 0;
_num = 0;
Expand All @@ -114,7 +114,7 @@ void Histogram::clear() {
}
}

void Histogram::add(long value) {
void GCHistogram::add(long value) {
int b = search(value);
_buckets[b] += 1;
if (_min > value) _min = value;
Expand All @@ -124,15 +124,15 @@ void Histogram::add(long value) {
_sum_squares += (value * value);
}

long Histogram::median() const { return percentile(50); }
long GCHistogram::median() const { return percentile(50); }

long Histogram::remap(double x, long x0, long x1, long y0,
long GCHistogram::remap(double x, long x0, long x1, long y0,
long y1) const {
//assert((x0 != x1 && y0 != y1), "sanity check");
return (long)(y0 + (x - x0) / (x1 - x0) * (y1 - y0));
}

long Histogram::percentile(double p) const {
long GCHistogram::percentile(double p) const {
if (0 == _num) return 0;

double threshold = (_num * (p / 100.0));
Expand Down Expand Up @@ -163,20 +163,20 @@ long Histogram::percentile(double p) const {
return _max;
}

double Histogram::average() const {
double GCHistogram::average() const {
if (0 == _num) return 0.0;
return (_sum * 1.0) / _num;
}

long Histogram::max() const {
long GCHistogram::max() const {
return _max;
}

long Histogram::min() const {
long GCHistogram::min() const {
return _min;
}

double Histogram::standard_deviation() const {
double GCHistogram::standard_deviation() const {
if (0 == _num) return 0.0;
double variance = (_sum_squares * _num * 1.0 - _sum * _sum) / (_num * _num);
return sqrt(variance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define SHARE_VM_SERVICES_HISTOGRAM_HPP

//This class provides a framework for collecting percentile statistics.
class Histogram {
class GCHistogram {
public:
enum BucketLevel {
LEVEL1 = 200,
Expand All @@ -34,12 +34,12 @@ class Histogram {
};

// Create a histogram with a default set of bucket boundaries.
Histogram();
GCHistogram();

// Create a histogram with a custom set of bucket boundaries,
explicit Histogram(long* custom_bucket_limits);
explicit GCHistogram(long* custom_bucket_limits);

~Histogram() {}
~GCHistogram() {}

void clear();
void add(long value);
Expand Down

0 comments on commit 8e9bb73

Please sign in to comment.