The method
Use Flame Graphs to visually represent the call stacks of your application, making it easier to spot performance bottlenecks. Input sampled call stack data and request the LLM to analyze for frequently called functions.
The prompts
Prompt 1
Analyze the following flame graph data to identify the top 3 functions that are consuming the most CPU time. Provide a summary of their call paths and suggest potential optimizations for each. The data is in folded stack format:
[Insert Flame Graph Data Here - e.g., "java.lang.Thread.run;com.example.MyClass.processData;com.example.MyClass.calculateValue 100", representing a call stack and its occurrence count]
[Insert Flame Graph Data Here - e.g., "java.lang.Thread.run;com.example.MyClass.processData;com.example.MyClass.calculateValue 100", representing a call stack and its occurrence count]
Prompt 2
I have a function called 'processData' showing up frequently in my flame graph. The call stack leading to it is 'java.lang.Thread.run;com.example.MyClass.handleRequest;com.example.MyClass.processData'. It appears to be related to handling incoming requests. Given this, suggest three specific optimization strategies I could explore to improve the performance of 'processData', considering potential issues like inefficient data structures, redundant calculations, or database access bottlenecks. Also, suggest tools to use. Limit the response to potential strategies and the tool to use. Focus on providing tangible improvements.