Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/query: relative comparisons #4578

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

pkg/query: relative comparisons #4578

wants to merge 3 commits into from

Conversation

metalmatze
Copy link
Member

When comparing profiles, people usually want to compare relatively, meaning they care about the relative percentages that changed between the profiles, not about the exact times a stack has been seen.
This change ensures that we scale both profiles to the same total cumulative value for the root and then multiply each diff value by the ratio between both roots.

Comment on lines 773 to 805
diff := multiplyInt64By(mem, columns[len(columns)-4].(*array.Int64), -1*cumulativeRatio)
defer diff.Release()
diffPerSecond := multiplyFloat64By(mem, columns[len(columns)-3].(*array.Float64), -1)
diffPerSecond := multiplyFloat64By(mem, columns[len(columns)-3].(*array.Float64), -1*cumulativePerSecondRatio)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, only this side of the comparison is changed. However, if this side has the higher total cumulative value, we need to "scale" it down. Meaning that we sometimes calculate new values with 1 * 0.95 which results in 0 for the int64 columns.
In that case, we probably should instead "scale" the other side up, right? Basically making it a calculation of 1 * 1.05 which would still be 1 once casted back to int64.

Copy link

alwaysmeticulous bot commented May 6, 2024

🤖 Meticulous spotted visual differences in 1 of 434 screens tested: view and approve differences detected.

Last updated for commit bc2754a. This comment will update as new commits are pushed.

@metalmatze metalmatze changed the title WIP: pkg/query: relative comparisons pkg/query: relative comparisons May 7, 2024
@metalmatze
Copy link
Member Author

Now, we need to figure out the UX and UI to enable or disable the relative comparison.
Most likely, a toggle that will show when comparing makes the most sense.

pkg/query/columnquery.go Outdated Show resolved Hide resolved
pkg/query/columnquery.go Outdated Show resolved Hide resolved
When comparing profiles, people usually want to compare relatively, meaning they care about the relative percentages that changed between the profiles, not about the exact times a stack has been seen.
This change ensures that we scale both profiles to the same total cumulative value for the root and then multiply each diff value by the ratio between both roots.
Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This largely looks good except for one small comment, but I'm actually more wondering about the UX of this, as we have plenty of evidence that suggests that people want to do both absolute and relative comparisons, depending on the situation, so we should allow users to do both, but with this patch we'd only allow them to do relative comparisons.

} else {
cumulativeCompareRatio = float64(totalBaseValue) / float64(totalCompareValue)
}
if totalCompareValuePerSecond > totalBaseValuePerSecond {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two if statements here doesn't make sense to me, that would mean we can have a situation where we're scaling cumulative based on one side and per second on the other. We should always scale the same side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants