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

*: Display CPU cores and CPU seconds for samples count profiles #4304

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

brancz
Copy link
Member

@brancz brancz commented Feb 14, 2024

This patch changes the UX of interacting with CPU profiling data that only reports samples count. It ensures that samples count is multiplied by their period (the time between samples), which allows comparing two profiles that were taken at different frequencies.

As a side effect while changing the queries, this also fixed an issue where the average cpu time was previously summed up over a step period, which was incorrect, as the total cpu time over the step needs to be divided by the total duration over the step.

Copy link

alwaysmeticulous bot commented Feb 14, 2024

🤖 Meticulous spotted visual differences in 183 of 375 screens tested: view and approve differences detected.

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

Copy link
Member

@metalmatze metalmatze left a comment

Choose a reason for hiding this comment

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

Super nice!

parca.yaml Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This was probably pushed by accident.

Comment on lines +366 to +370
preProjection := []logicalplan.Expr{
logicalplan.Mul(logicalplan.Div(logicalplan.Col(profile.ColumnTimestamp), logicalplan.Literal(step.Milliseconds())), logicalplan.Literal(step.Milliseconds())).Alias(profile.ColumnTimestamp),
logicalplan.DynCol(profile.ColumnLabels),
logicalplan.Col(profile.ColumnDuration),
}
Copy link
Member

Choose a reason for hiding this comment

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

🤩

parca.yaml Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this got pushed by accident.

Comment on lines -488 to -500
// Because we store the period with each sample yet query for the sum(period) we need to normalize by the amount of values (rows in a database).
period := periodSum / valueCount
// Because we store the duration with each sample yet query for the sum(duration) we need to normalize by the amount of values (rows in a database).
duration := durationSum / valueCount

// If we have a CPU samples value type we make sure we always do the next calculation with cpu nanoseconds.
// If we already have CPU nanoseconds we don't need to multiply by the period.
valuePerSecondSum := valueSum
if sampleTypeUnit != "nanoseconds" {
valuePerSecondSum = valueSum * period
}

valuePerSecond := float64(valuePerSecondSum) / float64(duration)
Copy link
Member

Choose a reason for hiding this comment

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

👏

This patch changes the UX of interacting with CPU profiling data that
only reports samples count. It ensures that samples count is multiplied
by their period (the time between samples), which allows comparing two
profiles that were taken at different frequencies.

As a side effect while changing the queries, this also fixed an issue
where the average cpu time was previously summed up over a step period,
which was incorrect, as the total cpu time over the step needs to be
divided by the total duration over the step.
@brancz brancz merged commit 648182e into main Feb 14, 2024
35 of 38 checks passed
@brancz brancz deleted the cpu-seconds branch February 14, 2024 14:41
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.

2 participants