Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

8341427: JFR: Adjust object sampler span handling #19334

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,25 @@ void ObjectSampler::add(HeapWord* obj, size_t allocated, traceid thread_id, bool
// quick reject, will not fit
return;
}
sample = _list->reuse(_priority_queue->pop());
ObjectSample* popped = _priority_queue->pop();
size_t popped_span = popped->span();
ObjectSample* previous = popped->prev();
sample = _list->reuse(popped);
assert(sample != nullptr, "invariant");
if (previous != nullptr) {
push_span(previous, popped_span);
sample->set_span(span);
} else {
// The removed sample was the youngest sample in the list, which means the new sample is now the youngest
// sample. It should cover the spans of both.
sample->set_span(span + popped_span);
}
} else {
sample = _list->get();
assert(sample != nullptr, "invariant");
sample->set_span(span);
}

assert(sample != nullptr, "invariant");
signal_unresolved_entry();
sample->set_thread_id(thread_id);
if (virtual_thread) {
Expand All @@ -278,7 +291,6 @@ void ObjectSampler::add(HeapWord* obj, size_t allocated, traceid thread_id, bool
sample->set_stack_trace_hash(stacktrace_hash);
}

sample->set_span(allocated);
sample->set_object(cast_to_oop(obj));
sample->set_allocated(allocated);
sample->set_allocation_time(JfrTicks::now());
Expand All @@ -305,14 +317,18 @@ void ObjectSampler::remove_dead(ObjectSample* sample) {
ObjectSample* const previous = sample->prev();
// push span onto previous
if (previous != nullptr) {
_priority_queue->remove(previous);
previous->add_span(sample->span());
_priority_queue->push(previous);
push_span(previous, sample->span());
}
_priority_queue->remove(sample);
_list->release(sample);
}

void ObjectSampler::push_span(ObjectSample* sample, size_t span) {
_priority_queue->remove(sample);
sample->add_span(span);
_priority_queue->push(sample);
}

ObjectSample* ObjectSampler::last() const {
return _list->last();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ObjectSampler : public CHeapObj<mtTracing> {
void add(HeapWord* object, size_t size, traceid thread_id, bool virtual_thread, const JfrBlobHandle& bh, JavaThread* thread);
void scavenge();
void remove_dead(ObjectSample* sample);
void push_span(ObjectSample* sample, size_t span);

const ObjectSample* item_at(int index) const;
ObjectSample* item_at(int index);
Expand Down