Repository navigation
Init PD Rust LB (PO2) - #6437
Conversation
fzyzcjy
left a comment
There was a problem hiding this comment.
LGTM since we do not (yet) need to squeeze out the last bit of performance here, thus only some nits
|
lgtm overall |
fzyzcjy
left a comment
There was a problem hiding this comment.
LGTM, only (optional) nits, if in a hurry then just merge this first and update it later.
| ); | ||
| } else { | ||
| self.set_bootstrap_info( | ||
| BootstrapHost::Single(prefill_info.get_hostname()), |
There was a problem hiding this comment.
nit: use From/Into, then can write prefill_info.get_hostname().into() and no need to repeat the Single
| timeout: 600, | ||
| }; | ||
| let lb_state = server::LBState::new(lb_config.clone()).map_err(|e| anyhow::anyhow!(e))?; | ||
| let ret: anyhow::Result<()> = actix_web::rt::System::new().block_on(async move { |
There was a problem hiding this comment.
nit: looks like there are some code dup b/t this and lib.rs, shall we extract to a function
| async fn generate( | ||
| &self, | ||
| api_path: &str, | ||
| mut req: Box<dyn Bootstrap>, |
There was a problem hiding this comment.
| mut req: Box<dyn Bootstrap>, | |
| mut req: &impl Bootstrap, |
(or use full generic)
| Ok(HttpResponse::Ok().json(json!({ | ||
| "prefill": prefill_loads.into_iter().map(|l| l.to_json()).collect::<Vec<_>>(), | ||
| "decode": decode_loads.into_iter().map(|l| l.to_json()).collect::<Vec<_>>() | ||
| }))) |
There was a problem hiding this comment.
fn get_loads(){
fn _transform(loads) { loads.into_iter().map().collec() }
Ok(HttpResponse::Ok().json(json!({
"prefill": _transform(prefill_loads)
"decode": _transform(decode_loads)
})))
}
| let decode_index = rng.random_range(0..self.decode_servers.len()); | ||
|
|
||
| ( | ||
| self.prefill_servers[prefill_index].clone(), |
There was a problem hiding this comment.
nit: maybe return (&EngineInfo, &EngineInfo) to avoid clone
| } | ||
| } | ||
|
|
||
| async fn select_pd_pair_po2(&self, client: &reqwest::Client) -> (EngineInfo, EngineInfo) { |
There was a problem hiding this comment.
eg naively
fn get_engine_and_load(servers: &[What]) {
let server = servers[rng ... ];
let load = self.get_load_from_engine(client, &a).await;
(server, load)
}
fn select_pd_item_po2(servers: &[What]) {
let (a, a_load) = get_engine_and_load();
let (b, b_load) = get_engine_and_load();
if a_load < b_load { a } else { b }
}
fn select_pd_pair_po2() {
(
select_pd_item_po2(&prefill_servers),
select_pd_item_po2(&decode_servers),
)
}
The power-of-two random choices implementation of PD LB. Currently, we use the occupied tokens and waiting tokens to denote the load for each server.
The PO2 will be improved in the following PRs, including the load reporter and algorithm part.