STRA-338 size-fn: desktop-core bin: option dispatch, owner table and one test within the limits
This commit is contained in:
@@ -77,7 +77,11 @@ fn spawn_choice(
|
||||
|
||||
/// The owner variant the selection names, with the error text for its missing ranked profile.
|
||||
fn owner_spawner(selection: &Selection) -> Option<(OwnerSpawn, &'static str)> {
|
||||
let owners: [(bool, OwnerSpawn, &'static str); 5] = [
|
||||
adaptive_resident_scratch_spawner(selection).or_else(|| spill_queued_spawner(selection))
|
||||
}
|
||||
|
||||
fn adaptive_resident_scratch_spawner(selection: &Selection) -> Option<(OwnerSpawn, &'static str)> {
|
||||
let owners: [(bool, OwnerSpawn, &'static str); 3] = [
|
||||
(
|
||||
selection.adaptive_slots,
|
||||
spawn_backend_experimental_optimized_windowed256_adaptive_slots,
|
||||
@@ -93,6 +97,12 @@ fn owner_spawner(selection: &Selection) -> Option<(OwnerSpawn, &'static str)> {
|
||||
spawn_backend_experimental_optimized_windowed256_retained_scratch,
|
||||
"retained_scratch_requires_ranked_expert_profile",
|
||||
),
|
||||
];
|
||||
first_selected(owners)
|
||||
}
|
||||
|
||||
fn spill_queued_spawner(selection: &Selection) -> Option<(OwnerSpawn, &'static str)> {
|
||||
let owners: [(bool, OwnerSpawn, &'static str); 2] = [
|
||||
(
|
||||
selection.streamed_spill,
|
||||
spawn_backend_experimental_optimized_windowed256_streamed_spill,
|
||||
@@ -104,6 +114,12 @@ fn owner_spawner(selection: &Selection) -> Option<(OwnerSpawn, &'static str)> {
|
||||
"queued_owners_require_ranked_expert_profile",
|
||||
),
|
||||
];
|
||||
first_selected(owners)
|
||||
}
|
||||
|
||||
fn first_selected<const N: usize>(
|
||||
owners: [(bool, OwnerSpawn, &'static str); N],
|
||||
) -> Option<(OwnerSpawn, &'static str)> {
|
||||
owners
|
||||
.into_iter()
|
||||
.find(|(selected, ..)| *selected)
|
||||
|
||||
@@ -76,6 +76,16 @@ mod original_serve_operator_tests {
|
||||
])
|
||||
}
|
||||
|
||||
fn assert_bad_expert_sources_refused() {
|
||||
for bad in [
|
||||
args(&["--expert-source"]),
|
||||
args(&["--expert-source", "copy"]),
|
||||
args(&["--expert-source", "mapped", "--expert-source", "resident"]),
|
||||
] {
|
||||
assert!(operator_original_serve(&bad).is_err(), "{bad:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expert_source_is_resident_by_default_and_mapped_on_request() {
|
||||
let (_, options, rest) = operator_original_serve(&args(&[])).unwrap();
|
||||
@@ -103,13 +113,7 @@ mod original_serve_operator_tests {
|
||||
"/a.json"
|
||||
])
|
||||
);
|
||||
for bad in [
|
||||
args(&["--expert-source"]),
|
||||
args(&["--expert-source", "copy"]),
|
||||
args(&["--expert-source", "mapped", "--expert-source", "resident"]),
|
||||
] {
|
||||
assert!(operator_original_serve(&bad).is_err(), "{bad:?}");
|
||||
}
|
||||
assert_bad_expert_sources_refused();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -82,38 +82,38 @@ impl OriginalServeParser {
|
||||
}
|
||||
|
||||
fn apply_engine_option(&mut self, flag: &str, value: OptionValue<'_>) -> Result<bool, Fault> {
|
||||
match flag {
|
||||
BACKEND_MODE_FLAG => self.backend_mode(value)?,
|
||||
ORIGINAL_PREFILL_CAPACITY_FLAG => self.prefill_capacity(value)?,
|
||||
MTP_RT_DIR_FLAG => self.mtp_directory(value)?,
|
||||
SPEC_MIN_P_FLAG => self.spec_min_p(value)?,
|
||||
KV_FLAG => self.kv_format(value)?,
|
||||
KV_RESIDENT_FLAG => self.kv_resident(value)?,
|
||||
EXPERT_SOURCE_FLAG => self.expert_source(value)?,
|
||||
let applied = match flag {
|
||||
BACKEND_MODE_FLAG => self.backend_mode(value),
|
||||
ORIGINAL_PREFILL_CAPACITY_FLAG => self.prefill_capacity(value),
|
||||
MTP_RT_DIR_FLAG => self.mtp_directory(value),
|
||||
SPEC_MIN_P_FLAG => self.spec_min_p(value),
|
||||
KV_FLAG => self.kv_format(value),
|
||||
KV_RESIDENT_FLAG => self.kv_resident(value),
|
||||
EXPERT_SOURCE_FLAG => self.expert_source(value),
|
||||
_ => return Ok(false),
|
||||
}
|
||||
Ok(true)
|
||||
};
|
||||
applied.map(|()| true)
|
||||
}
|
||||
|
||||
fn apply_cache_option(&mut self, flag: &str, value: OptionValue<'_>) -> Result<bool, Fault> {
|
||||
match flag {
|
||||
PROMPT_CACHE_FLAG => self.prompt_cache(value)?,
|
||||
PROMPT_CACHE_EVERY_FLAG => self.prompt_cache_every(value)?,
|
||||
PROMPT_CACHE_ROOT_FLAG => self.prompt_cache_root(value)?,
|
||||
TURN_TOKEN_FLAG => self.turn_token(value)?,
|
||||
let applied = match flag {
|
||||
PROMPT_CACHE_FLAG => self.prompt_cache(value),
|
||||
PROMPT_CACHE_EVERY_FLAG => self.prompt_cache_every(value),
|
||||
PROMPT_CACHE_ROOT_FLAG => self.prompt_cache_root(value),
|
||||
TURN_TOKEN_FLAG => self.turn_token(value),
|
||||
_ => return Ok(false),
|
||||
}
|
||||
Ok(true)
|
||||
};
|
||||
applied.map(|()| true)
|
||||
}
|
||||
|
||||
fn apply_prefix_option(&mut self, flag: &str, value: OptionValue<'_>) -> Result<bool, Fault> {
|
||||
match flag {
|
||||
PREFIX_CACHE_MIB_FLAG => self.prefix_cache_budget(value)?,
|
||||
PREFIX_CACHE_TAIL_FLAG => self.prefix_cache_tail(value)?,
|
||||
PREFIX_CACHE_BLOCK_FLAG => self.prefix_cache_block(value)?,
|
||||
let applied = match flag {
|
||||
PREFIX_CACHE_MIB_FLAG => self.prefix_cache_budget(value),
|
||||
PREFIX_CACHE_TAIL_FLAG => self.prefix_cache_tail(value),
|
||||
PREFIX_CACHE_BLOCK_FLAG => self.prefix_cache_block(value),
|
||||
_ => return Ok(false),
|
||||
}
|
||||
Ok(true)
|
||||
};
|
||||
applied.map(|()| true)
|
||||
}
|
||||
|
||||
fn backend_mode(&mut self, value: OptionValue<'_>) -> Result<(), Fault> {
|
||||
|
||||
Reference in New Issue
Block a user