-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: Info and infoUnion should always be synced #26707
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideAdds histogram-based percentile tracking (p90/p95/p99) to RuntimeMetric with JSON-serializable configuration, updates RuntimeStats and StageExecutionStateMachine to optionally track percentiles for selected metrics, extends QueryMonitor to read TableFinishInfo from both JSON and Thrift unions, and introduces comprehensive tests for percentile behavior and merging semantics. Sequence diagram for recording metrics with percentile tracking and computing percentilessequenceDiagram
actor Coordinator
participant StageExecutionStateMachine as StageExecutionStateMachine
participant RuntimeStats as RuntimeStats
participant RuntimeMetric as RuntimeMetric
Coordinator->>StageExecutionStateMachine: recordStartWaitForEventLoop(nanos)
StageExecutionStateMachine->>RuntimeStats: addMetricValue(TASK_START_WAIT_FOR_EVENT_LOOP, NANO, max(nanos,0), true)
alt metric_exists
RuntimeStats->>RuntimeMetric: addValue(value)
RuntimeMetric->>RuntimeMetric: update sum/count/min/max
RuntimeMetric->>RuntimeMetric: getBucketIndex(value)
RuntimeMetric->>RuntimeMetric: histogramBuckets.incrementAndGet(bucketIndex)
else metric_missing
RuntimeStats->>RuntimeStats: create new RuntimeMetric(name, unit, trackPercentiles=true)
RuntimeStats->>RuntimeMetric: addValue(value)
RuntimeMetric->>RuntimeMetric: update sum/count/min/max
RuntimeMetric->>RuntimeMetric: getBucketIndex(value)
RuntimeMetric->>RuntimeMetric: histogramBuckets.incrementAndGet(bucketIndex)
end
Coordinator->>RuntimeStats: computeAllPercentiles()
loop for_each_metric
RuntimeStats->>RuntimeMetric: isPercentileTrackingEnabled()
alt tracking_enabled
RuntimeStats->>RuntimeMetric: getP90()
RuntimeMetric->>RuntimeMetric: computePercentile(0.90)
RuntimeMetric-->>RuntimeStats: p90
RuntimeStats->>RuntimeMetric: getP95()
RuntimeMetric->>RuntimeMetric: computePercentile(0.95)
RuntimeMetric-->>RuntimeStats: p95
RuntimeStats->>RuntimeMetric: getP99()
RuntimeMetric->>RuntimeMetric: computePercentile(0.99)
RuntimeMetric-->>RuntimeStats: p99
else tracking_disabled
RuntimeStats-->>RuntimeStats: skip_metric
end
end
Sequence diagram for QueryMonitor resolving TableFinishInfo from JSON and Thrift unionsequenceDiagram
participant QueryMonitor as QueryMonitor
participant QueryInfo as QueryInfo
participant QueryStats as QueryStats
participant OperatorStats as OperatorStats
participant OperatorInfoUnion as OperatorInfoUnion
participant TableFinishInfo as TableFinishInfo
QueryMonitor->>QueryInfo: getOutput()
alt output_present
QueryMonitor->>QueryInfo: getQueryStats()
QueryInfo-->>QueryMonitor: QueryStats
QueryMonitor->>QueryStats: getOperatorSummaries()
QueryStats-->>QueryMonitor: List~OperatorStats~
loop operator_summaries
QueryMonitor->>OperatorStats: getInfo()
alt info_is_TableFinishInfo
OperatorStats-->>QueryMonitor: TableFinishInfo
QueryMonitor-->>TableFinishInfo: use_for_QueryOutputMetadata
else info_not_TableFinishInfo
OperatorStats-->>QueryMonitor: OperatorInfo
QueryMonitor->>OperatorStats: getInfoUnion()
alt infoUnion_not_null
OperatorStats-->>QueryMonitor: OperatorInfoUnion
QueryMonitor->>OperatorInfoUnion: getTableFinishInfo()
alt union_has_TableFinishInfo
OperatorInfoUnion-->>QueryMonitor: TableFinishInfo
QueryMonitor-->>TableFinishInfo: use_for_QueryOutputMetadata
else union_missing_TableFinishInfo
OperatorInfoUnion-->>QueryMonitor: null
end
else infoUnion_null
OperatorStats-->>QueryMonitor: null
end
end
end
else output_absent
QueryInfo-->>QueryMonitor: Optional.empty
QueryMonitor-->>QueryMonitor: no_QueryOutputMetadata
end
Class diagram for updated RuntimeMetric and RuntimeStats percentile trackingclassDiagram
class RuntimeMetric {
- static int DEFAULT_NUM_BUCKETS
- int numBuckets
- long bucketWidth
- String name
- RuntimeUnit unit
- AtomicLong sum
- AtomicLong count
- AtomicLong max
- AtomicLong min
- boolean percentileTrackingEnabled
- AtomicLongArray histogramBuckets
- Long p90
- Long p95
- Long p99
+ RuntimeMetric(name String, unit RuntimeUnit)
+ RuntimeMetric(name String, unit RuntimeUnit, trackPercentiles boolean)
+ RuntimeMetric(name String, unit RuntimeUnit, trackPercentiles boolean, bucketWidth long)
+ RuntimeMetric(name String, unit RuntimeUnit, trackPercentiles boolean, bucketWidth long, numBuckets int)
+ RuntimeMetric(name String, unit RuntimeUnit, sum long, count long, max long, min long)
+ RuntimeMetric(name String, unit RuntimeUnit, sum long, count long, max long, min long, numBuckets Integer, bucketWidth Long, p90 Long, p95 Long, p99 Long)
+ static RuntimeMetric copyOf(metric RuntimeMetric) RuntimeMetric
- static long determineBucketWidth(unit RuntimeUnit) long
- void set(sum long, count long, max long, min long)
+ void set(metric RuntimeMetric)
+ boolean isPercentileTrackingEnabled()
+ String getName()
+ void addValue(value long)
- int getBucketIndex(value long) int
+ void mergeWith(metric RuntimeMetric)
+ long getSum()
+ long getCount()
+ long getMax()
+ long getMin()
+ RuntimeUnit getUnit()
+ Integer getNumBuckets()
+ Long getBucketWidth()
+ Long getP90()
+ Long getP95()
+ Long getP99()
- long computePercentile(percentile double) long
- static void checkState(condition boolean, message String)
+ String toString()
}
class RuntimeStats {
- Map~String, RuntimeMetric~ metrics
+ RuntimeStats()
+ Map~String, RuntimeMetric~ getMetrics()
+ void addMetricValue(name String, unit RuntimeUnit, value long)
+ void addMetricValue(name String, unit RuntimeUnit, value long, trackPercentiles boolean)
+ void addMetricValueIgnoreZero(name String, unit RuntimeUnit, value long)
+ void addMetricValueIgnoreZero(name String, unit RuntimeUnit, value long, trackPercentiles boolean)
+ void addMetric(name String, metric RuntimeMetric)
+ void mergeWith(other RuntimeStats)
+ void recordWallTime(tag String, runnable Runnable)
+ void recordCpuTime(tag String, supplier Supplier~Object~)
+ void recordWallAndCpuTime(tag String, supplier Supplier~Object~)
+ void computeAllPercentiles()
}
class StageExecutionStateMachine {
- RuntimeStats runtimeStats
+ void recordStartWaitForEventLoop(nanos long)
+ void recordTaskUpdateDeliveredTime(nanos long)
+ void recordDeliveredUpdates(updates int)
}
RuntimeStats --> RuntimeMetric : uses
StageExecutionStateMachine --> RuntimeStats : uses
StageExecutionStateMachine ..> RuntimeMetric : records_metrics_with_percentiles
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
0f42f69 to
9fceba9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- In
RuntimeMetric.set(RuntimeMetric)you now enforce same bucketWidth/numBuckets even when percentile tracking is effectively unused, which may be unnecessarily strict and could break existing call sites that only care about the basic aggregates; consider gating those checks on both metrics having percentile tracking enabled. - The new
RuntimeStats.addMetricValue(name, unit, value, trackPercentiles)ignorestrackPercentilesafter the first insertion because ofcomputeIfAbsent; if a caller ever expects to turn percentile tracking on for an existing metric, that will silently fail, so it might be worth either documenting or enforcing that the flag is consistent per name.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `RuntimeMetric.set(RuntimeMetric)` you now enforce same bucketWidth/numBuckets even when percentile tracking is effectively unused, which may be unnecessarily strict and could break existing call sites that only care about the basic aggregates; consider gating those checks on both metrics having percentile tracking enabled.
- The new `RuntimeStats.addMetricValue(name, unit, value, trackPercentiles)` ignores `trackPercentiles` after the first insertion because of `computeIfAbsent`; if a caller ever expects to turn percentile tracking on for an existing metric, that will silently fail, so it might be worth either documenting or enforcing that the flag is consistent per name.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
14e2938 to
27014b8
Compare
presto-main-base/src/main/java/com/facebook/presto/operator/OperatorInfoUnion.java
Outdated
Show resolved
Hide resolved
27014b8 to
392c0e2
Compare
392c0e2 to
d238477
Compare
Description
Motivation and Context
Impact
Test Plan
passed verifier run
Contributor checklist
Release Notes