-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
12
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.
+249
−9
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f9333a3
Log GC vtime on VM exit
JonasNorlinder 4eaa6e1
Add elapsed_process_vtime
fisk e43bf02
Refactor vtime logic in evaluate_operation into a stack object and ca…
JonasNorlinder dbf314c
Remove unused bool
JonasNorlinder b9a3432
Remove unnecessary assert
JonasNorlinder aeb4ad0
Refactor shared logic into CollectedHeap, remove nominal logging and …
JonasNorlinder fc6acd5
Add bug fix after refactor and fixes for review
JonasNorlinder dec5b8b
Replace calls to log_gc_vtime with super-class method calls
JonasNorlinder 895f374
Add CPU time tracking for string deduplication to log_gc_vtime
JonasNorlinder effaeed
Remove explicit super call and minor fixes
JonasNorlinder 2ac0032
Only sample if needed
JonasNorlinder b20c974
operation_is_gc -> is_gc_operation per @stefank suggestion
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
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,42 @@ | ||
/* | ||
* 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 _gcLogging; | ||
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,55 @@ | ||
/* | ||
* 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 "logging/log.hpp" | ||
#include "memory/universe.hpp" | ||
#include "runtime/vmThread.hpp" | ||
#include "runtime/cpuTimeCounters.hpp" | ||
#include "runtime/os.hpp" | ||
|
||
inline VTimeScope::VTimeScope(VMThread* thread, bool is_gc_operation) | ||
: _start(0), _enabled(os::is_thread_cpu_time_supported()), | ||
_gcLogging(is_gc_operation && log_is_enabled(Info, gc)), | ||
_thread(thread) { | ||
if (_gcLogging && _enabled) { | ||
_start = os::thread_cpu_time(_thread); | ||
} | ||
} | ||
|
||
inline VTimeScope::~VTimeScope() { | ||
if (_enabled) { | ||
jlong end = _gcLogging || UsePerfData ? os::thread_cpu_time(_thread) : 0; | ||
|
||
if (_gcLogging) { | ||
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
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.
Nit: if you put this in the .hpp file you can do away with the forward decl for VMThread that is in there.