in oap-server/server-library/library-async-profiler-jfr-parser/src/main/java/org/apache/skywalking/oap/server/library/jfr/parser/JFRToFrameTree.java [56:114]
protected void convertChunk() throws IOException {
Map<JFREventType, EventAggregator> event2aggMap = collectMultiEvents();
for (Map.Entry<JFREventType, EventAggregator> entry : event2aggMap.entrySet()) {
JFREventType event = entry.getKey();
EventAggregator agg = entry.getValue();
FrameTreeBuilder frameTreeBuilder = event2builderMap.computeIfAbsent(event, eventType -> new FrameTreeBuilder());
agg.forEach(new EventAggregator.Visitor() {
final CallStack stack = new CallStack();
final double ticksToNanos = 1e9 / jfr.ticksPerSec;
final boolean scale = JFREventType.isLockSample(event) && ticksToNanos != 1.0;
@Override
public void visit(Event event, long value) {
StackTrace stackTrace = jfr.stackTraces.get(event.stackTraceId);
if (stackTrace != null) {
long[] methods = stackTrace.methods;
byte[] types = stackTrace.types;
int[] locations = stackTrace.locations;
if (args.isThreads()) {
stack.push(getThreadName(event.tid), TYPE_NATIVE);
}
if (args.isClassify()) {
Classifier.Category category = getCategory(stackTrace);
stack.push(category.getTitle(), category.getType());
}
for (int i = methods.length; --i >= 0; ) {
String methodName = getMethodName(methods[i], types[i]);
int location;
if ((location = locations[i] >>> 16) != 0) {
methodName += ":" + location;
}
stack.push(methodName, types[i]);
}
if (event instanceof AllocationSample) {
AllocationSample allocationSample = (AllocationSample) event;
if (allocationSample.classId != 0) {
stack.push(getClassName(allocationSample.classId), ((AllocationSample) event).tlabSize == 0 ? TYPE_KERNEL : TYPE_INLINED);
}
} else if (event instanceof LiveObject) {
LiveObject liveObject = (LiveObject) event;
if (liveObject.classId != 0) {
stack.push(getClassName(liveObject.classId), TYPE_INLINED);
}
} else if (event instanceof ContendedLock) {
ContendedLock contendedLock = (ContendedLock) event;
if (contendedLock.classId != 0) {
stack.push(getClassName(contendedLock.classId), TYPE_INLINED);
}
}
frameTreeBuilder.addSample(stack, scale ? (long) (value * ticksToNanos) : value);
stack.clear();
}
}
});
}
}