Skip to content

Commit

Permalink
Set active work to be not less than 2 and not more than input size
Browse files Browse the repository at this point in the history
Values less than 2 are not accepted.

Input size constraint comes from our CI that is so slow, it cannot allow very large active work sizes
  • Loading branch information
akoshelev committed Jul 4, 2024
1 parent bfdd0f3 commit 4a6b43b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions ipa-core/src/helpers/transport/query/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
cmp::{max, min},
fmt::{Debug, Display, Formatter},
num::NonZeroU32,
num::{NonZeroU32, NonZeroUsize},
};

use serde::{Deserialize, Deserializer, Serialize};
Expand Down Expand Up @@ -140,9 +141,25 @@ impl RouteParams<RouteId, NoQueryId, NoStep> for &QueryConfig {
}

impl From<&QueryConfig> for GatewayConfig {
fn from(_value: &QueryConfig) -> Self {
// TODO: pick the correct value for active and test it
Self::default()
fn from(value: &QueryConfig) -> Self {
let mut config = Self::default();
// Minimum size for active work is 2 because:
// * `UnorderedReceiver` wants capacity to be greater than 1
// * 1 is better represented by not using seq_join and/or indeterminate total records
let active = max(
2,
min(
config.active.get(),
// It makes sense to start with active work set to input size, but some protocols
// may want to change that, if their fanout factor per input row is greater than 1.
// we don't have capabilities (see #ipa/1171) to allow that currently.
usize::try_from(value.size.0).expect("u32 fits into usize"),
),
);
// we set active to be at least 2, so unwrap is fine.
config.active = NonZeroUsize::new(active).unwrap();

config
}
}

Expand Down

0 comments on commit 4a6b43b

Please sign in to comment.