docs/en/setup/backend/backend-profile-thread-merging.md
The performance profile is an enhancement feature in the APM system. We are using the thread dump to estimate the method execution time, rather than adding multiple local spans. In this way, the resource cost would be much less than using distributed tracing to locate slow method. This feature is suitable in the production environment. This document introduces how thread dumps are merged into the final report as a stack tree(s).
Read the data from the database and convert it to a data structure in gRPC.
st=>start: Start
e=>end: End
op1=>operation: Load data using paging
op2=>operation: Transform data using parallel
st(right)->op1(right)->op2
op2(right)->e
Copy the code and paste it into this link to generate flow chart.
Use the group-by and collector modes in the Java parallel stream to group according to the first stack element in the database records, and use the collector to perform data aggregation. Generate a multi-root tree.
st=>start: Start
e=>end: End
op1=>operation: Group by first stack element
sup=>operation: Generate empty stack tree
acc=>operation: Accumulator data to stack tree
com=>operation: Combine stack trees
fin=>operation: Calculate durations and build result
st(right)->op1->sup(right)->acc
acc(right)->com(right)->fin->e
Copy the code and paste it into this link to generate a flow chart.
Accumulator.
Stack data structure to avoid recursive calls. Each stack element represents the node that needs to be merged.Combine stack trees step. Convert to a GraphQL data structure, and put all nodes into a list for subsequent duration calculations.Please follow the exporter tool to package profile data. Unzip the profile data and use analyzer main function to run it.