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

Add metrics for Accumulator and GroupByHash #24015

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

piotrrzysko
Copy link
Member

Description

Additional context and related issues

Fixes #21925

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Section
* Add metrics for accumulator and group by hash update time. ({issue}`21925`)

@cla-bot cla-bot bot added the cla-signed label Nov 3, 2024
@github-actions github-actions bot added the hive Hive connector label Nov 3, 2024
@wendigo wendigo requested a review from losipiuk November 4, 2024 11:19
Comment on lines 34 to 39
private long accumulatorTimeNanos;
private boolean hasAccumulator;
private long groupByHashTimeNanos;
private boolean hasGroupByHash;
private long inputRowsProcessedWithPartialAggregationDisabled;
private boolean hasInputRowsProcessedWithPartialAggregationDisabled;
Copy link
Member

Choose a reason for hiding this comment

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

why do we need those boolean flags?
Why not just return 0 for all those values by defualt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed what we already have in PageProcessorMetrics. Additionally, inputRowsProcessedWithPartialAggregationDisabled was handled in a similar way.

I assumed the reasoning was to avoid polluting the explain output with metrics that weren’t reported, as unreported metrics are irrelevant for a given operator.

Perhaps we could replace the boolean flags by checking if a given metric has a value greater than zero, and only expose it in the AggregationMetrics::getMetrics method in that case. WDYT?

Copy link
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

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

LGTM. One question

static final String INPUT_ROWS_WITH_PARTIAL_AGGREGATION_DISABLED_METRIC_NAME = "Input rows processed without partial aggregation enabled";

private long inputRowsProcessedWithPartialAggregationDisabled;
private boolean hasInputRowsProcessedWithPartialAggregationDisabled;
Copy link
Member

Choose a reason for hiding this comment

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

Why not just check if inputRowsProcessedWithPartialAggregationDisabled > 0?

{
ImmutableMap.Builder<String, Metric<?>> builder = ImmutableMap.builder();
if (hasInputRowsProcessedWithPartialAggregationDisabled) {
builder.put(INPUT_ROWS_WITH_PARTIAL_AGGREGATION_DISABLED_METRIC_NAME, new LongCount(inputRowsProcessedWithPartialAggregationDisabled));
Copy link
Member

Choose a reason for hiding this comment

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

Since this is part of explain analyze verbose we probably could print it always

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed this so that all these metrics are always printed.

Copy link
Member

@sopel39 sopel39 left a comment

Choose a reason for hiding this comment

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

lgtm % other comments

{
long start = System.nanoTime();
boolean result = delegate.process();
metrics.recordGroupByHashUpdateTimeSince(start);
Copy link
Member

Choose a reason for hiding this comment

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

nit: alternatively we could use OperationTiming as in

private final OperationTiming addInputTiming = new OperationTiming();
, which would also track number of calls and wall time.

But I'm fine keeping it as is for now

This is in preparation for including more metrics reported by
aggregation operators
@piotrrzysko
Copy link
Member Author

comments addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector
Development

Successfully merging this pull request may close these issues.

Improve stats reporting for group by operator
4 participants