8215113: Sampling interval not always correct

Fix the sampling interval

Reviewed-by: phh, sspitsyn
This commit is contained in:
Jean Christophe Beyler 2019-04-30 15:39:42 -07:00
parent aba919ab50
commit 4b6adaa5f1
7 changed files with 47 additions and 33 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -281,17 +281,21 @@ void ThreadLocalAllocBuffer::print_stats(const char* tag) {
_fast_refill_waste * HeapWordSize);
}
void ThreadLocalAllocBuffer::set_sample_end() {
void ThreadLocalAllocBuffer::set_sample_end(bool reset_byte_accumulation) {
size_t heap_words_remaining = pointer_delta(_end, _top);
size_t bytes_until_sample = thread()->heap_sampler().bytes_until_sample();
size_t words_until_sample = bytes_until_sample / HeapWordSize;
if (reset_byte_accumulation) {
_bytes_since_last_sample_point = 0;
}
if (heap_words_remaining > words_until_sample) {
HeapWord* new_end = _top + words_until_sample;
set_end(new_end);
_bytes_since_last_sample_point = bytes_until_sample;
_bytes_since_last_sample_point += bytes_until_sample;
} else {
_bytes_since_last_sample_point = heap_words_remaining * HeapWordSize;
_bytes_since_last_sample_point += heap_words_remaining * HeapWordSize;
}
}