quickperf icon indicating copy to clipboard operation
quickperf copied to clipboard

@ProfileHeapAllocation

Open jeanbisutti opened this issue 5 years ago • 1 comments

With @ProfileHeapAllocation, heap allocation profiling will be displayed in the console (http://hirt.se/blog/?p=381).

QuickPerf can already profile a test method with Java Flight Recorder. @ProfileHeapAllocation will extract heap allocation profiling data from this recording.

If you would like to have more details on this issue or some help to work on it, please leave a comment.

jeanbisutti avatar Jul 04 '19 13:07 jeanbisutti

Snippet code to extract data from JFR

            for(Iterator<IItemIterable> iterator = jfrEvents.iterator(); iterator.hasNext(); ) {
                IItemIterable item = iterator.next();
                if (item.hasItems()) {
                    IType<IItem> itemType = item.getType();
                    String itemId = itemType.getIdentifier();
                    System.out.println(itemId + ": count=" + item.getItemCount());
                
                    // jdk.ThreadAllocationStatistics
                    if ("jdk.ThreadAllocationStatistics".equals(itemId)) {
                        for(Iterator<IItem> items = item.iterator(); items.hasNext(); ) {
                            IItem iitem = items.next();
                            // System.out.println(iitem);
                        }
                        
                    }
                    // jdk.ObjectAllocationInNewTLAB
                    if ("jdk.ObjectAllocationInNewTLAB".equals(itemId)) {
                        IMemberAccessor<IMCThread, IItem> eventThreadAcc = JfrAttributes.EVENT_THREAD.getAccessor(itemType);
                        IMemberAccessor<IMCStackTrace, IItem> stackTraceAcc = JfrAttributes.EVENT_STACKTRACE.getAccessor(itemType);
                        
                        for(Iterator<IItem> items = item.iterator(); items.hasNext(); ) {
                            IItem iitem = items.next();
                            IMCThread eventThread = eventThreadAcc.getMember(iitem);
                            IMCStackTrace stackTrace = stackTraceAcc.getMember(iitem);
                            
                            System.out.println(iitem + " eventThread:" + eventThread + " stackTrace:" + stackTrace);
                        }
                        
                    }
                    
                    // jdk.ObjectAllocationOutsideTLAB
                }
            }

Arnaud-Nauwynck avatar Jan 28 '20 21:01 Arnaud-Nauwynck