8330677: Add Per-Compilation memory usage to JFR
Reviewed-by: kvn, mbaesken
This commit is contained in:
parent
7272939064
commit
151ef5d4d2
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, Red Hat, Inc. and/or its affiliates.
|
||||
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -394,16 +394,20 @@ void CompilationMemoryStatistic::on_end_compilation() {
|
||||
ResourceMark rm;
|
||||
CompilerThread* const th = Thread::current()->as_Compiler_thread();
|
||||
ArenaStatCounter* const arena_stat = th->arena_stat();
|
||||
const CompilerType ct = th->task()->compiler()->type();
|
||||
CompileTask* const task = th->task();
|
||||
const CompilerType ct = task->compiler()->type();
|
||||
|
||||
const Method* const m = th->task()->method();
|
||||
FullMethodName fmn(m);
|
||||
fmn.make_permanent();
|
||||
|
||||
const DirectiveSet* directive = th->task()->directive();
|
||||
assert(directive->should_collect_memstat(), "Only call if memstat is enabled");
|
||||
assert(directive->should_collect_memstat(), "Should only be called if memstat is enabled for this method");
|
||||
const bool print = directive->should_print_memstat();
|
||||
|
||||
// Store memory used in task, for later processing by JFR
|
||||
task->set_arena_bytes(arena_stat->peak_since_start());
|
||||
|
||||
// Store result
|
||||
// For this to work, we must call on_end_compilation() at a point where
|
||||
// Compile|Compilation already handed over the failure string to ciEnv,
|
||||
@ -492,7 +496,7 @@ void CompilationMemoryStatistic::on_arena_change(ssize_t diff, const Arena* aren
|
||||
CompilerType ct = compiler_none;
|
||||
|
||||
// get some more info
|
||||
const CompileTask* task = th->task();
|
||||
const CompileTask* const task = th->task();
|
||||
if (task != nullptr) {
|
||||
ct = task->compiler()->type();
|
||||
const DirectiveSet* directive = task->directive();
|
||||
|
@ -2126,7 +2126,8 @@ static void post_compilation_event(EventCompilation& event, CompileTask* task) {
|
||||
task->is_success(),
|
||||
task->osr_bci() != CompileBroker::standard_entry_bci,
|
||||
task->nm_total_size(),
|
||||
task->num_inlined_bytecodes());
|
||||
task->num_inlined_bytecodes(),
|
||||
task->arena_bytes());
|
||||
}
|
||||
|
||||
int DirectivesStack::_depth = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2024, 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
|
||||
@ -123,6 +123,7 @@ void CompileTask::initialize(int compile_id,
|
||||
_nm_total_size = 0;
|
||||
_failure_reason = nullptr;
|
||||
_failure_reason_on_C_heap = false;
|
||||
_arena_bytes = 0;
|
||||
|
||||
if (LogCompilation) {
|
||||
if (hot_method.not_null()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2024, 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
|
||||
@ -114,6 +114,7 @@ class CompileTask : public CHeapObj<mtCompiler> {
|
||||
const char* _failure_reason;
|
||||
// Specifies if _failure_reason is on the C heap.
|
||||
bool _failure_reason_on_C_heap;
|
||||
size_t _arena_bytes; // peak size of temporary memory during compilation (e.g. node arenas)
|
||||
|
||||
public:
|
||||
CompileTask() : _failure_reason(nullptr), _failure_reason_on_C_heap(false) {
|
||||
@ -200,6 +201,9 @@ class CompileTask : public CHeapObj<mtCompiler> {
|
||||
void metadata_do(MetadataClosure* f);
|
||||
void mark_on_stack();
|
||||
|
||||
void set_arena_bytes(size_t s) { _arena_bytes = s; }
|
||||
size_t arena_bytes() const { return _arena_bytes; }
|
||||
|
||||
private:
|
||||
static void print_impl(outputStream* st, Method* method, int compile_id, int comp_level,
|
||||
bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2024, 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
|
||||
@ -134,7 +134,9 @@ static inline void commit(EventType& event) {
|
||||
}
|
||||
}
|
||||
|
||||
void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_id, CompilerType compiler_type, Method* method, int compile_level, bool success, bool is_osr, int code_size, int inlined_bytecodes) {
|
||||
void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_id, CompilerType compiler_type, Method* method,
|
||||
int compile_level, bool success, bool is_osr, int code_size,
|
||||
int inlined_bytecodes, size_t arenaBytes) {
|
||||
event.set_compileId(compile_id);
|
||||
event.set_compiler(compiler_type);
|
||||
event.set_method(method);
|
||||
@ -143,6 +145,7 @@ void CompilerEvent::CompilationEvent::post(EventCompilation& event, int compile_
|
||||
event.set_isOsr(is_osr);
|
||||
event.set_codeSize(code_size);
|
||||
event.set_inlinedBytes(inlined_bytecodes);
|
||||
event.set_arenaBytes(arenaBytes);
|
||||
commit(event);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2024, 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
|
||||
@ -52,7 +52,9 @@ class CompilerEvent : AllStatic {
|
||||
|
||||
class CompilationEvent : AllStatic {
|
||||
public:
|
||||
static void post(EventCompilation& event, int compile_id, CompilerType type, Method* method, int compile_level, bool success, bool is_osr, int code_size, int inlined_bytecodes) NOT_JFR_RETURN();
|
||||
static void post(EventCompilation& event, int compile_id, CompilerType type, Method* method,
|
||||
int compile_level, bool success, bool is_osr, int code_size,
|
||||
int inlined_bytecodes, size_t arenaBytes) NOT_JFR_RETURN();
|
||||
};
|
||||
|
||||
class CompilationFailureEvent : AllStatic {
|
||||
|
@ -608,6 +608,7 @@
|
||||
<Field type="boolean" name="isOsr" label="On Stack Replacement" />
|
||||
<Field type="ulong" contentType="bytes" name="codeSize" label="Compiled Code Size" />
|
||||
<Field type="ulong" contentType="bytes" name="inlinedBytes" label="Inlined Code Size" />
|
||||
<Field type="ulong" contentType="bytes" name="arenaBytes" label="Arena Usage" />
|
||||
</Event>
|
||||
|
||||
<Event name="CompilerPhase" category="Java Virtual Machine, Compiler" label="Compiler Phase"
|
||||
|
@ -48,6 +48,7 @@ import jdk.test.whitebox.WhiteBox;
|
||||
* @run main/othervm -Xbootclasspath/a:.
|
||||
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
||||
* -XX:CompileOnly=jdk.jfr.event.compiler.TestCompilerCompile::dummyMethod,jdk.jfr.event.compiler.TestCompilerCompile::doTest
|
||||
* -XX:CompileCommand=MemStat,*.*
|
||||
* jdk.jfr.event.compiler.TestCompilerCompile
|
||||
*/
|
||||
public class TestCompilerCompile {
|
||||
@ -138,5 +139,6 @@ public class TestCompilerCompile {
|
||||
Events.assertField(event, "inlinedBytes").atLeast(0L);
|
||||
Events.assertField(event, "codeSize").atLeast(0L);
|
||||
Events.assertField(event, "isOsr");
|
||||
Events.assertField(event, "arenaBytes").atLeast(1024L);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user