< prev index next >
src/share/vm/jfr/periodic/sampling/jfrThreadSampler.cpp
Print this page
rev 9062 : 8215727: Restore JFR thread sampler loop to old / previous behavior
Reviewed-by: egahlin, mgronlun
Contributed-by: milan.mimica@gmail.com
rev 9063 : 8216283: Allow shorter method sampling interval than 10 ms
Reviewed-by: mgronlun
*** 283,299 ****
static const uint MAX_NR_OF_JAVA_SAMPLES = 5;
static const uint MAX_NR_OF_NATIVE_SAMPLES = 1;
void JfrThreadSampleClosure::commit_events(JfrSampleType type) {
if (JAVA_SAMPLE == type) {
! assert(_added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
for (uint i = 0; i < _added_java; ++i) {
_events[i].commit();
}
} else {
assert(NATIVE_SAMPLE == type, "invariant");
! assert(_added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
for (uint i = 0; i < _added_native; ++i) {
_events_native[i].commit();
}
}
}
--- 283,299 ----
static const uint MAX_NR_OF_JAVA_SAMPLES = 5;
static const uint MAX_NR_OF_NATIVE_SAMPLES = 1;
void JfrThreadSampleClosure::commit_events(JfrSampleType type) {
if (JAVA_SAMPLE == type) {
! assert(_added_java > 0 && _added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant");
for (uint i = 0; i < _added_java; ++i) {
_events[i].commit();
}
} else {
assert(NATIVE_SAMPLE == type, "invariant");
! assert(_added_native > 0 && _added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant");
for (uint i = 0; i < _added_native; ++i) {
_events_native[i].commit();
}
}
}
*** 492,503 ****
_sample.wait();
last_java_ms = get_monotonic_ms();
last_native_ms = last_java_ms;
}
_sample.signal();
! jlong java_interval = _interval_java == 0 ? max_jlong : MAX2<jlong>(_interval_java, 10);
! jlong native_interval = _interval_native == 0 ? max_jlong : MAX2<jlong>(_interval_native, 10);
jlong now_ms = get_monotonic_ms();
/*
* Let I be java_interval or native_interval.
--- 492,503 ----
_sample.wait();
last_java_ms = get_monotonic_ms();
last_native_ms = last_java_ms;
}
_sample.signal();
! jlong java_interval = _interval_java == 0 ? max_jlong : MAX2<jlong>(_interval_java, 1);
! jlong native_interval = _interval_native == 0 ? max_jlong : MAX2<jlong>(_interval_native, 1);
jlong now_ms = get_monotonic_ms();
/*
* Let I be java_interval or native_interval.
*** 535,545 ****
EventExecutionSample samples[MAX_NR_OF_JAVA_SAMPLES];
EventNativeMethodSample samples_native[MAX_NR_OF_NATIVE_SAMPLES];
JfrThreadSampleClosure sample_task(samples, samples_native);
const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES;
! uint num_sample_attempts = 0;
JavaThread* start = NULL;
{
elapsedTimer sample_time;
sample_time.start();
--- 535,545 ----
EventExecutionSample samples[MAX_NR_OF_JAVA_SAMPLES];
EventNativeMethodSample samples_native[MAX_NR_OF_NATIVE_SAMPLES];
JfrThreadSampleClosure sample_task(samples, samples_native);
const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES;
! uint num_samples = 0;
JavaThread* start = NULL;
{
elapsedTimer sample_time;
sample_time.start();
*** 553,584 ****
threads_list[index++] = tp;
}
JavaThread* current = Threads::includes(*last_thread) ? *last_thread : NULL;
JavaThread* start = NULL;
! while (num_sample_attempts < sample_limit) {
current = next_thread(threads_list, index, start, current);
if (current == NULL) {
break;
}
if (start == NULL) {
start = current; // remember the thread where we started to attempt sampling
}
if (current->is_Compiler_thread()) {
continue;
}
! sample_task.do_sample_thread(current, _frames, _max_frames, type);
! num_sample_attempts++;
}
*last_thread = current; // remember the thread we last attempted to sample
FREE_C_HEAP_ARRAY(JavaThread *, threads_list, mtInternal);
}
sample_time.stop();
if (LogJFR && Verbose) tty->print_cr("JFR thread sampling done in %3.7f secs with %d java %d native samples",
sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries());
}
! if (num_sample_attempts > 0) {
sample_task.commit_events(type);
}
}
static JfrThreadSampling* _instance = NULL;
--- 553,585 ----
threads_list[index++] = tp;
}
JavaThread* current = Threads::includes(*last_thread) ? *last_thread : NULL;
JavaThread* start = NULL;
! while (num_samples < sample_limit) {
current = next_thread(threads_list, index, start, current);
if (current == NULL) {
break;
}
if (start == NULL) {
start = current; // remember the thread where we started to attempt sampling
}
if (current->is_Compiler_thread()) {
continue;
}
! if (sample_task.do_sample_thread(current, _frames, _max_frames, type)) {
! num_samples++;
! }
}
*last_thread = current; // remember the thread we last attempted to sample
FREE_C_HEAP_ARRAY(JavaThread *, threads_list, mtInternal);
}
sample_time.stop();
if (LogJFR && Verbose) tty->print_cr("JFR thread sampling done in %3.7f secs with %d java %d native samples",
sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries());
}
! if (num_samples > 0) {
sample_task.commit_events(type);
}
}
static JfrThreadSampling* _instance = NULL;
< prev index next >