-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359110: Log accumulated GC and process CPU time upon VM exit #25779
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
JonasNorlinder
wants to merge
16
commits into
openjdk:master
Choose a base branch
from
JonasNorlinder:gc_cpu_time
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.
+226
−10
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9ebd28a
Log GC vtime on VM exit
JonasNorlinder b600901
Add elapsed_process_vtime
fisk 3f91b87
Refactor vtime logic in evaluate_operation into a stack object and ca…
JonasNorlinder aafb91a
Remove unused bool
JonasNorlinder 13cdd8b
Remove unnecessary assert
JonasNorlinder 2a35786
Refactor shared logic into CollectedHeap, remove nominal logging and …
JonasNorlinder 77e3be0
Add bug fix after refactor and fixes for review
JonasNorlinder b275c9e
Replace calls to log_gc_vtime with super-class method calls
JonasNorlinder 81db6d8
Add CPU time tracking for string deduplication to log_gc_vtime
JonasNorlinder 21f2844
Remove explicit super call and minor fixes
JonasNorlinder 6e56027
Only sample if needed
JonasNorlinder a47ca98
operation_is_gc -> is_gc_operation per @stefank suggestion
JonasNorlinder 571b00d
Remove extra whitespace
fisk 1c65416
Fixes after feedback from @stefank
JonasNorlinder 3095e70
More clean up, remove virtual
JonasNorlinder 553edc4
Remove incorrect is_gc_operation call after rebase
JonasNorlinder 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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2025, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#ifndef SHARE_GC_SHARED_VTIMESCOPE_HPP | ||
#define SHARE_GC_SHARED_VTIMESCOPE_HPP | ||
|
||
#include "memory/allocation.hpp" | ||
|
||
class VMThread; | ||
|
||
class VTimeScope : public StackObj { | ||
private: | ||
jlong _start; | ||
bool _enabled; | ||
bool _is_gc_operation; | ||
Thread* _thread; | ||
|
||
public: | ||
VTimeScope(VMThread* thread, bool is_gc_operation); | ||
~VTimeScope(); | ||
}; | ||
|
||
#endif // SHARE_GC_SHARED_VTIMESCOPE_HPP |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2025, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
#include "gc/shared/vtimeScope.hpp" | ||
|
||
#include "gc/shared/collectedHeap.inline.hpp" | ||
#include "memory/universe.hpp" | ||
#include "runtime/cpuTimeCounters.hpp" | ||
#include "runtime/os.hpp" | ||
#include "runtime/vmThread.hpp" | ||
|
||
inline VTimeScope::VTimeScope(VMThread* thread, bool is_gc_operation) | ||
: _start(0), | ||
_enabled(os::is_thread_cpu_time_supported()), | ||
_is_gc_operation(is_gc_operation), | ||
_thread(thread) { | ||
if (_is_gc_operation && _enabled) { | ||
_start = os::thread_cpu_time(_thread); | ||
} | ||
} | ||
|
||
inline VTimeScope::~VTimeScope() { | ||
if (!_enabled) return; | ||
|
||
jlong end = (_is_gc_operation || UsePerfData) ? os::thread_cpu_time(_thread) : 0; | ||
|
||
if (_is_gc_operation) { | ||
jlong duration = end > _start ? end - _start : 0; | ||
Universe::heap()->add_vm_vtime(duration); | ||
} | ||
|
||
if (UsePerfData) { | ||
CPUTimeCounters::get_instance()->update_counter(CPUTimeGroups::CPUTimeType::vm, end); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.
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.
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.
I find it a bit odd to call
log_gc_vtime
inside this method, given the comment and its name. I wonder ifprint_tracing_info
can be used instead, which is invoked before exit as well.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.
I think it makes sense. We want to log the total GC CPU time before exiting. The latest point we can do that is right before we terminate threads, which we do in when we call
ConcurrentGCThread::stop
. I am open for any suggestions to renamelog_gc_vtime
in case that would help.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.
I'd also prefer to see a small adjustment here. With this change all GCs have to add a back call to
CollectedHeap::stop()
. I think it makes the could a tiny bit less clean.I wonder if an alternative could be to split
CollectedHeap::stop()
into two functions:And revert the added calls to
CollectedHeap::stop()
.