diff --git a/proto/anki/deck_config.proto b/proto/anki/deck_config.proto index bb9ead778..d983f10ea 100644 --- a/proto/anki/deck_config.proto +++ b/proto/anki/deck_config.proto @@ -193,6 +193,7 @@ message DeckConfig { reserved 39; float historical_retention = 40; string param_search = 45; + bool health_check = 47; bytes other = 255; } diff --git a/proto/anki/scheduler.proto b/proto/anki/scheduler.proto index 59372c64e..9bdde403e 100644 --- a/proto/anki/scheduler.proto +++ b/proto/anki/scheduler.proto @@ -354,6 +354,7 @@ message ComputeFsrsParamsRequest { repeated float current_params = 2; int64 ignore_revlogs_before_ms = 3; uint32 num_of_relearning_steps = 4; + bool health_check = 5; } message ComputeFsrsParamsResponse { diff --git a/rslib/src/deckconfig/mod.rs b/rslib/src/deckconfig/mod.rs index c522ea18a..c6ba7f8c6 100644 --- a/rslib/src/deckconfig/mod.rs +++ b/rslib/src/deckconfig/mod.rs @@ -78,6 +78,7 @@ const DEFAULT_DECK_CONFIG_INNER: DeckConfigInner = DeckConfigInner { fsrs_params_5: vec![], fsrs_params_6: vec![], desired_retention: 0.9, + health_check: false, other: Vec::new(), historical_retention: 0.9, param_search: String::new(), diff --git a/rslib/src/deckconfig/schema11.rs b/rslib/src/deckconfig/schema11.rs index 2d862a3a0..ac5979c1c 100644 --- a/rslib/src/deckconfig/schema11.rs +++ b/rslib/src/deckconfig/schema11.rs @@ -400,6 +400,7 @@ impl From for DeckConfig { desired_retention: c.desired_retention, historical_retention: c.sm2_retention, param_search: c.param_search, + health_check: false, other: other_bytes, }, } diff --git a/rslib/src/deckconfig/update.rs b/rslib/src/deckconfig/update.rs index 6d49bc5b1..5a85d92e1 100644 --- a/rslib/src/deckconfig/update.rs +++ b/rslib/src/deckconfig/update.rs @@ -372,6 +372,7 @@ impl Collection { config_len, config.fsrs_params(), num_of_relearning_steps, + false, ) { Ok(params) => { println!("{}: {:?}", config.name, params.params); diff --git a/rslib/src/scheduler/fsrs/params.rs b/rslib/src/scheduler/fsrs/params.rs index e30efba0e..45ab0a3c0 100644 --- a/rslib/src/scheduler/fsrs/params.rs +++ b/rslib/src/scheduler/fsrs/params.rs @@ -55,6 +55,7 @@ impl Collection { /// Note this does not return an error if there are less than 400 items - /// the caller should instead check the fsrs_items count in the return /// value. + #[allow(clippy::too_many_arguments)] pub fn compute_params( &mut self, search: &str, @@ -63,6 +64,7 @@ impl Collection { total_presets: u32, current_params: &Params, num_of_relearning_steps: usize, + health_check: bool, ) -> Result { self.clear_progress(); let timing = self.timing_today()?; @@ -75,7 +77,7 @@ impl Collection { return Ok(ComputeFsrsParamsResponse { params: current_params.to_vec(), fsrs_items, - log_loss: None + log_loss: None, }); } // adapt the progress handler to our built-in progress handling @@ -148,9 +150,14 @@ impl Collection { } } - let fsrs = FSRS::new(None)?; - let log_loss = fsrs - .evaluate_with_time_series_splits(input, |_| true).ok().map(|eval| eval.log_loss); + let log_loss = if health_check && *current_params != params { + let fsrs = FSRS::new(None)?; + fsrs.evaluate_with_time_series_splits(input, |_| true) + .ok() + .map(|eval| eval.log_loss) + } else { + None + }; Ok(ComputeFsrsParamsResponse { params, diff --git a/rslib/src/scheduler/service/mod.rs b/rslib/src/scheduler/service/mod.rs index 2ab647061..fde64007f 100644 --- a/rslib/src/scheduler/service/mod.rs +++ b/rslib/src/scheduler/service/mod.rs @@ -271,6 +271,7 @@ impl crate::services::SchedulerService for Collection { 1, &input.current_params, input.num_of_relearning_steps as usize, + input.health_check, ) } @@ -372,7 +373,11 @@ impl crate::services::BackendSchedulerService for Backend { enable_short_term: true, num_relearning_steps: None, })?; - Ok(ComputeFsrsParamsResponse { params, fsrs_items, log_loss: None }) + Ok(ComputeFsrsParamsResponse { + params, + fsrs_items, + log_loss: None, + }) } fn fsrs_benchmark( diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 866a71fdc..c657670e0 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -179,6 +179,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ignoreRevlogsBeforeMs: getIgnoreRevlogsBeforeMs(), currentParams: params, numOfRelearningSteps: numOfRelearningStepsInDay, + healthCheck: $config.healthCheck, }); const already_optimal = @@ -196,7 +197,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } else { $config.fsrsParams6 = resp.params; optimized = true; - console.log(`FSRS-test-train-split-log-loss = ${resp.logLoss}`) + console.log(`FSRS-test-train-split-log-loss = ${resp.logLoss}`); if (resp.logLoss && resp.logLoss > logLossBadThreshold) { setTimeout(() => alert(tr.deckConfigFsrsBadFitWarning())); } @@ -328,17 +329,24 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {tr.deckConfigOptimizeButton()} {/if} - + + {#if false} + + + {/if}
{#if computingParams || checkingParams} {computeParamsProgressString}