-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8373096: JFR leak profiler: path-to-gc-roots search should be non-recursive #28659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tstuefe
wants to merge
11
commits into
openjdk:master
Choose a base branch
from
tstuefe:JFR-leak-profiler-path-to-gc-roots-non-recursive
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
16e9a95
start
tstuefe 2189666
Copyright
tstuefe 5ac152d
remove test output
tstuefe e1a4736
fix
tstuefe 43b8fff
test improvements
tstuefe d5ee7c4
revert accidental checkin
tstuefe 73497c3
final fixes
tstuefe 10bc510
Merge branch 'master' into JFR-leak-profiler-path-to-gc-roots-non-rec…
tstuefe ad92650
revert part of the test changes
tstuefe 09886f4
completely revert test changes
tstuefe 94ce906
do strides for arrays
tstuefe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,8 @@ | |
| #include "oops/access.inline.hpp" | ||
| #include "oops/oop.inline.hpp" | ||
| #include "utilities/align.hpp" | ||
| #include "utilities/debug.hpp" | ||
| #include "utilities/stack.inline.hpp" | ||
|
|
||
| UnifiedOopRef DFSClosure::_reference_stack[max_dfs_depth]; | ||
|
|
||
|
|
@@ -48,6 +50,7 @@ void DFSClosure::find_leaks_from_edge(EdgeStore* edge_store, | |
| // Depth-first search, starting from a BFS edge | ||
| DFSClosure dfs(edge_store, mark_bits, start_edge); | ||
| start_edge->pointee()->oop_iterate(&dfs); | ||
| dfs.drain_probe_stack(); | ||
| } | ||
|
|
||
| void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store, | ||
|
|
@@ -60,52 +63,91 @@ void DFSClosure::find_leaks_from_root_set(EdgeStore* edge_store, | |
| dfs._max_depth = 1; | ||
| RootSetClosure<DFSClosure> rs(&dfs); | ||
| rs.process(); | ||
| dfs.drain_probe_stack(); | ||
|
|
||
| // Depth-first search | ||
| dfs._max_depth = max_dfs_depth; | ||
| dfs._ignore_root_set = true; | ||
| rs.process(); | ||
| dfs.drain_probe_stack(); | ||
| } | ||
|
|
||
| DFSClosure::DFSClosure(EdgeStore* edge_store, JFRBitSet* mark_bits, const Edge* start_edge) | ||
| :_edge_store(edge_store), _mark_bits(mark_bits), _start_edge(start_edge), | ||
| _max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false) { | ||
| _max_depth(max_dfs_depth), _depth(0), _ignore_root_set(false), | ||
| _probe_stack(MIN2(256UL, max_dfs_depth)) { | ||
| } | ||
|
|
||
| void DFSClosure::closure_impl(UnifiedOopRef reference, const oop pointee) { | ||
| assert(pointee != nullptr, "invariant"); | ||
| assert(!reference.is_null(), "invariant"); | ||
|
|
||
| if (GranularTimer::is_finished()) { | ||
| return; | ||
| } | ||
|
|
||
| if (_depth == 0 && _ignore_root_set) { | ||
| // Root set is already marked, but we want | ||
| // to continue, so skip is_marked check. | ||
| assert(_mark_bits->is_marked(pointee), "invariant"); | ||
| _reference_stack[_depth] = reference; | ||
| } else { | ||
| if (_mark_bits->is_marked(pointee)) { | ||
| return; | ||
| #ifdef ASSERT | ||
| DFSClosure::~DFSClosure() { | ||
| assert(_probe_stack.is_empty() || GranularTimer::is_finished(), | ||
| "Should have drained the probe stack"); | ||
| } | ||
| #endif // ASSERT | ||
|
|
||
| void DFSClosure::drain_probe_stack() { | ||
|
|
||
| while (!_probe_stack.is_empty() && | ||
| !GranularTimer::is_finished()) { | ||
|
|
||
| const ProbeStackItem psi = _probe_stack.pop(); | ||
|
|
||
| const UnifiedOopRef reference = psi.r; | ||
| assert(!reference.is_null(), "invariant"); | ||
| const oop pointee = reference.dereference(); | ||
| assert(pointee != nullptr, "invariant"); | ||
|
|
||
| _depth = psi.depth; | ||
|
|
||
| if (_depth == 0 && _ignore_root_set) { | ||
| // Root set is already marked, but we want | ||
| // to continue, so skip is_marked check. | ||
| assert(_mark_bits->is_marked(pointee), "invariant"); | ||
| _reference_stack[_depth] = reference; | ||
| } else { | ||
| if (_mark_bits->is_marked(pointee)) { | ||
| continue; | ||
| } | ||
| _mark_bits->mark_obj(pointee); | ||
| _reference_stack[_depth] = reference; | ||
| // is the pointee a sample object? | ||
| if (pointee->mark().is_marked()) { | ||
| add_chain(); | ||
| } | ||
| } | ||
| _mark_bits->mark_obj(pointee); | ||
| _reference_stack[_depth] = reference; | ||
| // is the pointee a sample object? | ||
| if (pointee->mark().is_marked()) { | ||
| add_chain(); | ||
| assert(_max_depth >= 1, "invariant"); | ||
| if (_depth < _max_depth - 1) { | ||
| _depth++; // increase range for do_oop() to pick up | ||
|
|
||
| if (pointee->is_objArray()) { | ||
| objArrayOop pointee_oa = (objArrayOop)pointee; | ||
| const int len = pointee_oa->length(); | ||
| // since our stack items are larger than those of GC marking stacks, | ||
| // we use a smaller stride | ||
| const int stridelen = MAX2((uintx)1, ObjArrayMarkingStride / 2); | ||
| const int begidx = psi.chunk * stridelen; | ||
| const int endidx = MIN2(len, (psi.chunk + 1) * stridelen); | ||
| if (endidx > begidx) { | ||
| if (endidx < len) { | ||
| ProbeStackItem psi2 = psi; | ||
| psi2.chunk ++; | ||
| _probe_stack.push(psi2); | ||
| tty->print_cr("adding cont task %u %d", psi2.depth, psi2.chunk); | ||
| } | ||
| pointee_oa->oop_iterate_range(this, begidx, endidx); | ||
| } | ||
| } else { | ||
| pointee->oop_iterate(this); | ||
| } | ||
|
|
||
| assert(_depth > 0, "invariant"); | ||
| _depth--; | ||
| } | ||
| } | ||
| assert(_max_depth >= 1, "invariant"); | ||
| if (_depth < _max_depth - 1) { | ||
| _depth++; | ||
| pointee->oop_iterate(this); | ||
| assert(_depth > 0, "invariant"); | ||
| _depth--; | ||
| } | ||
| } | ||
|
|
||
| void DFSClosure::add_chain() { | ||
|
|
||
| const size_t array_length = _depth + 2; | ||
|
|
||
| ResourceMark rm; | ||
|
|
@@ -135,7 +177,8 @@ void DFSClosure::do_oop(oop* ref) { | |
| assert(is_aligned(ref, HeapWordSize), "invariant"); | ||
| const oop pointee = HeapAccess<AS_NO_KEEPALIVE>::oop_load(ref); | ||
| if (pointee != nullptr) { | ||
| closure_impl(UnifiedOopRef::encode_in_heap(ref), pointee); | ||
| ProbeStackItem psi { UnifiedOopRef::encode_in_heap(ref), checked_cast<unsigned>(_depth), 0 }; | ||
| _probe_stack.push(psi); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -144,13 +187,15 @@ void DFSClosure::do_oop(narrowOop* ref) { | |
| assert(is_aligned(ref, sizeof(narrowOop)), "invariant"); | ||
| const oop pointee = HeapAccess<AS_NO_KEEPALIVE>::oop_load(ref); | ||
| if (pointee != nullptr) { | ||
| closure_impl(UnifiedOopRef::encode_in_heap(ref), pointee); | ||
| ProbeStackItem psi { UnifiedOopRef::encode_in_heap(ref), checked_cast<unsigned>(_depth), 0 }; | ||
| _probe_stack.push(psi); | ||
| } | ||
| } | ||
|
|
||
| void DFSClosure::do_root(UnifiedOopRef ref) { | ||
| assert(!ref.is_null(), "invariant"); | ||
| const oop pointee = ref.dereference(); | ||
| assert(pointee != nullptr, "invariant"); | ||
|
Comment on lines
197
to
198
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small thing: is this still useful since since |
||
| closure_impl(ref, pointee); | ||
| ProbeStackItem psi { ref, checked_cast<unsigned>(_depth), 0 }; | ||
| _probe_stack.push(psi); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could checking the marked status of
pointeenow become a problem ? To accomplish the striding, the samepointeeneeds to be revisited with the new chunk count to evaluate the next range. However, the next time it's popped off the stack, it will get skipped over on line 108 since it's already been marked.TestJcmdDumpPathToGCRootsBFSDFS.javapasses even after I addassert(psi.chunk==0 )in this block after line 122, which might indicate only the first range of each array is ever getting evaluated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I saw this yesterday too. The current version does not work. I am rethinking the solution.