#
What is sandwich view?Sandwich view is a mode of viewing flamegraphs popularized by Jamie Wong in the Speedscope project It's function is relatively simple -- the typical flamegraph will break down resource utilization by function, but it can be difficult to see how much time is spent in the function itself vs how much time is spent in the functions it calls. Sandwich view solves this problem by splitting a flamegraph into two sections:
- callers: the functions that called the function in question (it's "parents")
- callees: the functions that the function in question called (it's "children")
#
Finding performance issues with standard Flamegraph modeA typical use case for leveraging flamegraphs is to identify opportunities for optimization. With a typical flamegraph the most
common workflow is to identify a function node which has the largest width and then to look at the functions it calls to see if
there are any low hanging fruit for optimization.
For example, in the flamegraph below, we can see that the rideshare/car.OrderCar
is the largest function in terms of width and
thus a good place to start looking for opportunities for optimization.
#
Finding performance issues with sandwich view Flamegraph modeHowever, you'll also notice that Time.Since()
shows up frequently towards the end of almost every path.
Sandwich view helps you focus in on functions like this to analyze your application and determine if it's easier to optimize:
Time.Since()
: a node with a shorter width that gets called frequently across many code paths discovered with sandwich viewrideshare/car.OrderCar
: a node with a longer width, that gets called infrequently in a single code path discovered with standard flamegraph view
#
How to use sandwich view for your flamegraphsIf you want to try it out simply go to your Pyroscope UI or upload a flamegraph to flamegraph.com and select the "sandwich" view icon in the new Flamegraph toolbar:
then select a function to see it's callers and callees. We have many more view modes planned for the future, so stay tuned or let us know what you'd like to see!