perf: reduce CompletedTrial cloning overhead
- Add Trial::into_completed() and into_multi_objective_trial() to move fields instead of cloning 5 HashMaps/Vecs per trial completion - Fire after_trial callback before pushing to storage, eliminating the clone-from-storage pattern at all 4 call sites - Optimize top_trials(n) to sort indices and clone only N trials instead of cloning all completed trials - Remove unused set_complete/set_pruned methods
This commit is contained in:
@@ -117,6 +117,11 @@ pub trait Objective<V: PartialOrd = f64> {
|
||||
|
||||
/// Called after each **completed** trial (not failed or pruned).
|
||||
///
|
||||
/// The trial is passed directly as the argument *before* it is pushed
|
||||
/// to storage, so `study.n_trials()` and `study.trials()` do not yet
|
||||
/// include this trial. The trial is always pushed to storage after this
|
||||
/// callback returns, regardless of the return value.
|
||||
///
|
||||
/// Return `ControlFlow::Break(())` to stop the optimization loop.
|
||||
///
|
||||
/// Default: always continues.
|
||||
|
||||
Reference in New Issue
Block a user