-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Gateway supports dp rank scheduling and scheduling with the minimun number of tokens #20435
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
Open
jiashaokun-1
wants to merge
1
commit into
sgl-project:main
Choose a base branch
from
jiashaokun-1:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,9 @@ | ||||||||||||||||||
| use std::collections::HashMap; | ||||||||||||||||||
|
|
||||||||||||||||||
| use anyhow::ensure; | ||||||||||||||||||
| use openmetrics_parser::{MetricFamily, MetricsExposition, PrometheusType, PrometheusValue}; | ||||||||||||||||||
| use openmetrics_parser::{ | ||||||||||||||||||
| MetricFamily, MetricNumber, MetricsExposition, PrometheusType, PrometheusValue, | ||||||||||||||||||
| }; | ||||||||||||||||||
| use tracing::warn; | ||||||||||||||||||
|
|
||||||||||||||||||
| #[derive(Debug)] | ||||||||||||||||||
|
|
@@ -89,3 +93,78 @@ where | |||||||||||||||||
|
|
||||||||||||||||||
| Ok(Some(it.try_fold(first, f)?)) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| pub fn extract_gauge_metrics(text: String, target_metric_family: &str) -> HashMap<isize, isize> { | ||||||||||||||||||
| let metrics_text = text.replace(":", "_"); | ||||||||||||||||||
| let exposition = match openmetrics_parser::prometheus::parse_prometheus(&metrics_text) { | ||||||||||||||||||
| Ok(x) => x, | ||||||||||||||||||
| Err(err) => { | ||||||||||||||||||
| warn!( | ||||||||||||||||||
| "parse_load_response error when parsing text: pack={:?} err={:?}", | ||||||||||||||||||
| metrics_text, err | ||||||||||||||||||
| ); | ||||||||||||||||||
| return HashMap::new(); | ||||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
| extract_metrics( | ||||||||||||||||||
| &exposition, | ||||||||||||||||||
| target_metric_family, | ||||||||||||||||||
| &PrometheusValue::Gauge(MetricNumber::Float(0.0)), | ||||||||||||||||||
| ) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| pub fn extract_metrics( | ||||||||||||||||||
| exposition: &PrometheusExposition, | ||||||||||||||||||
| target_metric_family: &str, | ||||||||||||||||||
| target_value_type: &PrometheusValue, | ||||||||||||||||||
| ) -> HashMap<isize, isize> { | ||||||||||||||||||
| let mut result = HashMap::new(); | ||||||||||||||||||
| let Some(target_families) = exposition.families.get(target_metric_family) else { | ||||||||||||||||||
| warn!("{} don't exist!", target_metric_family); | ||||||||||||||||||
| return result; | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| for sample in target_families.iter_samples() { | ||||||||||||||||||
| let label_set = match sample.get_labelset() { | ||||||||||||||||||
| Ok(l_set) => l_set, | ||||||||||||||||||
| Err(e) => { | ||||||||||||||||||
| warn!("The metric is missing the dp_rank label{}, skipping.", e); | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+130
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning message here seems to be incorrect. The error
Suggested change
|
||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let dp_rank_str = match label_set.get_label_value("dp_rank") { | ||||||||||||||||||
| Some(val) => val, | ||||||||||||||||||
| None => { | ||||||||||||||||||
| warn!("Don't find dp_rank"); | ||||||||||||||||||
| "0" | ||||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let dp_rank = match dp_rank_str.parse::<isize>() { | ||||||||||||||||||
| Ok(rank_num) => rank_num, | ||||||||||||||||||
| Err(e) => { | ||||||||||||||||||
| warn!( | ||||||||||||||||||
| "Failed to parse dp_rank value {} as number: {}", | ||||||||||||||||||
| dp_rank_str, e | ||||||||||||||||||
| ); | ||||||||||||||||||
| 0 | ||||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let metric_value = match (&target_value_type, &sample.value) { | ||||||||||||||||||
| (PrometheusValue::Gauge(_), PrometheusValue::Gauge(val)) => val.as_f64(), | ||||||||||||||||||
| (target_type, actual_type) => { | ||||||||||||||||||
| warn!( | ||||||||||||||||||
| "Unadapted PrometheusValue. Expected:{:?}, Actual:{:?}.", | ||||||||||||||||||
| target_type, actual_type | ||||||||||||||||||
| ); | ||||||||||||||||||
| continue; | ||||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let value = metric_value as isize; | ||||||||||||||||||
| result.insert(dp_rank, value); | ||||||||||||||||||
| } | ||||||||||||||||||
| result | ||||||||||||||||||
| } | ||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The docstring for
worker_load_check_intervalis a bit misleading. It says "...for worker initialization", which suggests it's only used during startup. This interval is for periodic load checking during the router's lifetime. A clearer description would be better.