-
Notifications
You must be signed in to change notification settings - Fork 937
Latency Profiling enhancements #1499
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
Conversation
Hi team, thanks for the feedback. This PR currently does a bit more than what I was expecting:
I'll need some more changes to get the following:
I see two ways to move forward:
Any thoughts @apangin ? |
I propose the following action table:
Q:
|
Discussed offline, we'll remove
|
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.
Clang-Tidy
found issue(s) with the introduced code (1/1)
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.
Clang-Tidy
found issue(s) with the introduced code (1/1)
0e983bf
to
a50dd59
Compare
e264b07
to
e01247e
Compare
This reverts commit 12b4ce7.
Not really, all these changes should go together as they don't really make sense without each other now. I proposed to split them here, but my comment did not receive any reaction. |
src/instrument.cpp
Outdated
// Make sure the class is rewritten, constant pool reconstitution | ||
// doesn't always work (JDK-8216547) |
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.
How is JDK-8216547 related here?
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.
When I have if (name == NULL) return
in the ClassFileLoadHook
i get a segfault with this stacktrace:
V [libjvm.so+0xa9a409] Symbol::as_C_string() const+0x9
V [libjvm.so+0x4e6cd1] ConstantPool::copy_cpool_bytes(int, SymbolHashMap*, unsigned char*)+0x191
V [libjvm.so+0x75d83c] JvmtiClassFileReconstituter::write_class_file_format()+0x2cc
V [libjvm.so+0x7b4f5f] JvmtiEnv::RetransformClasses(int, _jclass* const*)+0x78f
V [libjvm.so+0x7600a6] jvmti_RetransformClasses+0x136
C [libasyncProfiler.so+0xea53] VM::RetransformClassesHook(_jvmtiEnv*, int, _jclass* const*)+0x23
C [libasyncProfiler.so+0x1ea6d] Instrument::retransformMatchedClasses(_jvmtiEnv*) [clone .constprop.0]+0xcd
C [libasyncProfiler.so+0x1ecbf] Instrument::stop()+0x2f
C [libasyncProfiler.so+0x4b61d] Profiler::stop(bool)+0xbd
C [libasyncProfiler.so+0x5468f] Profiler::runInternal(Arguments&, Writer&)+0x14f
C [libasyncProfiler.so+0x55326] Profiler::run(Arguments&)+0xc6
C [libasyncProfiler.so+0x5605e] VM::VMDeath(_jvmtiEnv*, JNIEnv_*)+0x4e
V [libjvm.so+0x7c1b69] JvmtiExport::post_vm_death()+0x1f9
V [libjvm.so+0x69dfbf] before_exit(JavaThread*)+0x12f
V [libjvm.so+0xae450b] Threads::destroy_vm()+0x34b
V [libjvm.so+0x7110cf] jni_DestroyJavaVM+0x7f
C [libjli.so+0x8618] JavaMain+0x5c8
C [libc.so.6+0x891f5]
My impression is that the class data is corrupted somehow and needs to be copied from the original version, which is more or less what is happening in the ticket. I could investigate more if you want to understand the root cause, but it only affects jdk8 and I figured it's not a priority.
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.
This works fine:
if (name == NULL) {
VM::jvmti()->Allocate(class_data_len, new_class_data);
memcpy(*new_class_data, class_data, class_data_len);
*new_class_data_len = class_data_len;
return;
}
but does not support the request you had the other day, that we should support the feature even when name == NULL
by getting the name from class_data
.
src/instrument.cpp
Outdated
u16 name_idx = _cpool[i]->info(); | ||
const auto& it = _targets->find(_cpool[name_idx]->as_string()); | ||
if (it == _targets->end()) { | ||
_target_methods = &EMPTY_METHOD_TARGETS; |
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.
EMPTY_METHOD_TARGETS
does not make sense to me.
If there is nothing to rewrite, return immediately.
If returning NULL from ClassFileLoadHook
does not work for some reason (I still don't understand why), you can just copy _src
to _dst
, and that's it.
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.
If returning NULL from ClassFileLoadHook does not work for some reason (I still don't understand why),
See here
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.
just copy _src to _dst, and that's it.
Check Result::ABORTED
: 5696577
Signed-off-by: Andrei Pangin <1749416+apangin@users.noreply.github.com>
Description
--latency
in favor of--trace
--trace A.B
: latency=0, wildcard signature--trace A.B(JJ)V
: latency=0--trace A.B(JJ)V+10ms
: latency=10ms--trace A.B+10ms
: latency=10ms, wildcard signature--trace
can appear multiple times in the arguments--trace
can target multiple methods in the same or different classes--trace
takes one independent latency threshold for each targetevent=A.B
will always perform "old" instrumentationargs._include/exclude
now usestd::vector
Related issues
#1421
Motivation and context
This feature is nice to have for users, latency profiling should not exclude other profiling modes.
How has this been tested?
New tests.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.