Skip to content

minor: Fix metric values of costBased auto-scaler#19641

Open
kfaraz wants to merge 5 commits into
apache:masterfrom
kfaraz:fix_autoscaler_metric_values
Open

minor: Fix metric values of costBased auto-scaler#19641
kfaraz wants to merge 5 commits into
apache:masterfrom
kfaraz:fix_autoscaler_metric_values

Conversation

@kfaraz

@kfaraz kfaraz commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Retain lagCost and idleCost metrics (which were removed recently in minor: Add metrics to costBased auto-scaler #19631 ) but do not document them
  • These metrics would help relate the cost function to physical quantities
  • Fix the emitted values of lagWeight and idleWeight
  • Do not emit invalid values for avgProcessingRate and avgPollIdleRatio
  • Remove unused auto-scaler config field minTriggerScaleActionFrequency. Use default constants instead.
  • Break up the test method testComputeValidTaskCounts into multiple test cases

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 6 of 6 changed files.

Found 1 issue: the cost-based autoscaler no longer honors the deprecated cooldown field as the documented fallback, which can change behavior for existing persisted specs.


This is an automated review by Codex GPT-5.5

Duration.millis(this.minTriggerScaleActionFrequencyMillis)
);
this.minScaleDownDelay = Configs.valueOrDefault(minScaleDownDelay, DEFAULT_MIN_SCALE_DELAY);
this.minScaleUpDelay = Configs.valueOrDefault(minScaleUpDelay, DEFAULT_MIN_SCALE_UP_DELAY);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] Preserve the legacy cooldown fallback

Existing cost-based supervisor specs can still contain minTriggerScaleActionFrequencyMillis, and the shared AutoScalerConfig contract/docs say minScaleUpDelay and minScaleDownDelay fall back to it when the Duration fields are absent. This PR removes the creator parameter and always defaults minScaleUpDelay to DEFAULT_MIN_SCALE_UP_DELAY, while the getter now returns -1, so a persisted spec that only set the deprecated field is accepted but silently changes its scale-up cooldown on upgrade. Please continue binding the legacy value and using it as the fallback until the field is actually removed, or migrate the public contract/docs and persisted-spec behavior together.

}
if (metrics.getPollIdleRatio() >= 0) {
emitter.emit(getMetricBuilder().setMetric(AVG_POLL_IDLE_RATIO, metrics.getPollIdleRatio()));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd also would like to request you to emit estimateIdleRatioFromProcessingRate() as separate metric for better tracking.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

change it please just to "idle ratio"

currentTaskCount,
metrics.getAvgPartitionLag(),
metrics.getAvgProcessingRate(),
metrics.getPollIdleRatio(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Call either getPollIdleRatio() or estimateIdleRatioFromProcessingRate(), whatever is active

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Handled in #19646

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I reviewed the new commits since the previous review and the full current diff for correctness, edge cases, concurrency, and integration risks. No new issues found in the latest changes.

Reviewed 6 of 6 changed files.

The previously reported compatibility issue around minTriggerScaleActionFrequencyMillis remains unresolved in the current head.


This is an automated review by Codex GPT-5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants