Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Pause Resume Attach Detach design of profilers"

(Complement attach/detach changes)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Initial Pause/Resume, Attach/Detach Design  ==
 +
 
Three old design overview documents (PPT) are attached:  
 
Three old design overview documents (PPT) are attached:  
  
Line 5: Line 7:
 
#[https://bugs.eclipse.org/bugs/attachment.cgi?id=149427 Thread Profiler Attach and Detach ]
 
#[https://bugs.eclipse.org/bugs/attachment.cgi?id=149427 Thread Profiler Attach and Detach ]
  
These three old slides can be a reference. The changes in current TPTP profilers code will be described as below.
+
These three old slides can be a reference. The changes in current TPTP profilers code will be described as below.  
 +
 
 +
== Attach/Detach Design Changes  ==
 +
 
 +
Now TPTP uses JVMTI instrumentation as profiling basis. However, in attach/detach scenarios, some happened events maybe lost if a profiler is attached to running Java apps. For example when using CGProf on below simple Java code snippet:
  
Now TPTP uses JVMTI instrumentation as profiling basis. However, in attach/detach scenarios, some happened events maybe lost if a profiler is attached to running Java apps. For example when using CGProf on below simple Java code snippet:
+
....
  
....
+
MethodA()
  
MethodA()
+
{
  
{
+
  ...
  
  ...
+
  // Attach happens here
  
  // Attach happens here
+
  MethodB();
  
  MethodB();
+
  ...
  
  ...
+
}
  
}
+
<br>
  
 +
When attach happens, we can catch MethodB enter but we don't know MethodA. This is because we can not instrument our code into entered methods (See bug 194081, bug 270767). Similar problem also exists in heap profiler: We can not catch some objects allocated before attach happens. To solve this problem, we use shadow stack track for CGProf and heap iteration for HeapProf. Heap iteration solution uses JVMTI iterate heap interface when attach happens in order to catch live objects in heap. Shadow stack track is a little complicated. One design document about shadow stack track solution process, classes and algorithm is [https://bugs.eclipse.org/bugs/attachment.cgi?id=136463 here]. There is also [https://bugs.eclipse.org/bugs/attachment.cgi?id=139605 a slide](PowerPoint) which contains animation explaining how shadow stack solution works.
  
 +
For Heap profiler, live objects iteration is used. A design document for this iteration process is recorded in [https://bugs.eclipse.org/bugs/attachment.cgi?id=115223 this file]&nbsp;for bug 241085. Please note, a problem related with on stack replacement (OSR) still exists which is reported in bug 296895.
  
When attach happens, we can catch MethodB enter but we don't know MethodA. This is because we can not instrument our code into entered methods (See bug 194081, bug 270767). Similar problem also exists in heap profiler: We can not catch some objects allocated before attach happens. To solve this problem, we use shadow stack track for CGProf and heap iteration for HeapProf. Heap iteration solution uses JVMTI iterate heap interface when attach happens in order to catch live objects in heap. Shadow stack track is a little complicated. One design document about shadow stack track solution process, classes and algorithm is [https://bugs.eclipse.org/bugs/attachment.cgi?id=136463 here]. There is also [https://bugs.eclipse.org/bugs/attachment.cgi?id=139605 a slide](PowerPoint) which contains animation explaining how shadow stack solution works.
+
----
 +
<div></div><div><span class="Apple-style-span" style="font-family: arial;">←[http://wiki.eclipse.org/TPTP Back to TPTP wiki page]</span></div>

Latest revision as of 18:18, 13 December 2009

Initial Pause/Resume, Attach/Detach Design

Three old design overview documents (PPT) are attached:

  1. CPU Profiler Attach and Detach
  2. Heap Profiler Attach and Detach
  3. Thread Profiler Attach and Detach

These three old slides can be a reference. The changes in current TPTP profilers code will be described as below.

Attach/Detach Design Changes

Now TPTP uses JVMTI instrumentation as profiling basis. However, in attach/detach scenarios, some happened events maybe lost if a profiler is attached to running Java apps. For example when using CGProf on below simple Java code snippet:

....

MethodA()

{

  ...

  // Attach happens here

  MethodB();

  ...

}


When attach happens, we can catch MethodB enter but we don't know MethodA. This is because we can not instrument our code into entered methods (See bug 194081, bug 270767). Similar problem also exists in heap profiler: We can not catch some objects allocated before attach happens. To solve this problem, we use shadow stack track for CGProf and heap iteration for HeapProf. Heap iteration solution uses JVMTI iterate heap interface when attach happens in order to catch live objects in heap. Shadow stack track is a little complicated. One design document about shadow stack track solution process, classes and algorithm is here. There is also a slide(PowerPoint) which contains animation explaining how shadow stack solution works.

For Heap profiler, live objects iteration is used. A design document for this iteration process is recorded in this file for bug 241085. Please note, a problem related with on stack replacement (OSR) still exists which is reported in bug 296895.


Back to the top