Stackdriver Profiler lets you visually compare two profiles of the same type, taken from the same service within a project. You can compare profiles that differ by:
- Ending times: Does the service run faster at certain times? Has there been a gradual improvement or decline over time?
- Zones: Does the service run faster in some zones than in others?
- Service versions: Do newer versions differ markedly from older ones? How?
- Weight: How do profiles captured during high consumption periods differ from average profiles?
Setting up a comparison
When you set up a comparison, you specify the parameters for an original profile and a compared profile. These two profiles share all configuration parameters except the one defined by the Compare to field.
To configure a comparison, do the following:
Set the comparison type by selecting an option from the Compare to menu:
Selecting one of these options results in a new configuration field. The field name begins with Compared and ends with the comparison type. For example, if you select Version, a Compared version field is displayed next to the Compare to field.
Specify the compared profile by selecting an option from the Compared menu.
For example, in the following the screenshot, the original profile is defined by the following fields:
- End time:
3/25/19, 10:20 AM
- Profile type:
The compared profile has the same values for all of these fields except
Version. Its value for Verison is
Understanding a comparison graph
The graph that results from a comparison differs from the standard graph in the following ways:
- Meaning of colors
- Meaning of function-block size
- Metric information displayed by the tooltip
- Contents of the focus list
Meaning of colors
In a standard flame graph, you can specify the color mode of the graph. For more details, go to Color mode.
In a comparison flame graph, the colors represent the difference between the total metric consumption of the function in the original profile and in the compared profile:
- Gray: There is little or no difference.
- Red: The difference is positive.
- Blue: The difference is negative.
The larger the difference in consumption values, the more saturated the color.
For example, in the previous figure, the
foo1 call stack is blue, indicating
that the original profile consumed less CPU than the compared profile.
foo1 is a brighter blue than its child frame
bar, indicating that
there is a larger difference in metric consumption for the function
than for the function
foo2 call stack is red, indicating that the
original profile consumed more CPU than the compared profile.
Meaning of block size
In a standard flame graph, the size of the function blocks illustrates the relative consumption of the metric being analyzed.
In a comparison flame graph, the size of the function blocks illustrates the relative average consumption of the metric being analyzed. By averaging the values for the two profiles, a block that exists only in one profile still appears in the comparison graph, at half its pre-comparison size.
Displayed metric values
In a standard flame graph, the metrics displayed by the tooltip is composed of two clauses, total and self. In both clauses, the absolute value is displayed along with a percentage:
total: 3.16 s, 100 %; self: 80 microsec, 0.0003%
In a comparison flame graph, because there are two profiles being compared, the tooltip displays the metric values for both profiles:
As shown in the figure, the total and self clauses have the following form:
[ABS_ORIGINAL] vs. [ABS_COMPARED] ([ABS_DIFF]), [REL_ORIGINAL] vs. [REL_COMPARED] ([REL_DIFF])
In this expression,
ABS_ means the absolute value and
REL_ means the relative percentage. Therefore,
[ABS_ORIGINAL] is the
absolute value for
the original profile and
[ABS_COMPARED] is the absolute value for the compared
profile. The field
[ABS_DIFF], defined as
is the absolute difference between the two profiles. When
the absolute difference is zero, no change is displayed.
The percentage is computed for each profile as the ratio of a function's raw
value to root's raw value. For example, if for the original profile
foo1 for took 1.58 seconds and
root took 3.17 seconds, then
[REL_ORIGINAL] is about 50%. A similar computation is performed for the
compared profile. Lastly, the field
[REL_DIFF], defined as the difference of
these percentages, is the relative difference between the two profiles.
When this difference is zero, no change is displayed.
For the preceding example, the total clause shows that the function
the original profile executes in 1.59 seconds. The absolute difference of
-515.32 milliseconds indicates that
foo1 executes about 515 milliseconds
faster in the original profile than the same function in the compared profile:
total: 1.59 s vs. 2.11 s (-515.32ms), 49.9% vs 66% (-16.6%)
Focusing a comparison
In a standard flame graph, each row in the Focus list contains a function name, the self and total metric consumption values, and the count of call stacks into that function.
In the comparison flame graph, each row in the Focus list contains a function name, the self and total metric consumption values, and the count of call stacks into that function for the original profile. In addition to the fields just described, the focus list includes two columns labeled Diff, a button labeled Relative Diff, and a button labeled Absolute Diff. For information on the relative difference and absolute difference, go to Displayed metric values.
By default, the comparison flame graph is colored by the absolute differences between the original and compared profiles. In contrast, by default, the focus list displays the relative differences between the two profiles being compared:
The table in the example shows that the function
foo1 takes about
1.59 seconds to run in the original profile. The time 1.59 seconds corresponds
to about 49.9% of the runtime. The Diff column contains the value of
-16.6%. This value indicates that
foo1 takes about 66% of the runtime
for the compared profile.
To view the absolute difference between metric values, click Absolute Diff.
Whether you have a standard flame graph or a comparison flame graph, you can sort the table rows in ascendingor descending order by selecting a table header element.
Turning off comparison mode
To turn off comparison mode, set the Compare to field to None.