mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-06 20:02:16 +00:00
Model cache: a thinned model keeps the check mode only as the model records it
SavedModel::thinned wrote `"validation": null` into the records of a model that records no check mode, so a thinned model was never the model it came from, even with room for every state, and its manifest grew by that key (design::tests::a_thinned_model_keeps_the_final_state_then_the_slowest_that_fit, a_model_cache_too_big_for_the_file_keeps_fewer_states). It copies the mode when there is one and adds nothing otherwise; the tests' timeline model records one, as every saved model does now, and a thinned model is asserted to keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -538,11 +538,15 @@ impl SavedModel {
|
||||
};
|
||||
out_features.push(f);
|
||||
}
|
||||
let records = json!({
|
||||
let mut records = json!({
|
||||
"features": out_features, "states": out_states, "model_bodies": out_bodies, "names": kept_of(names.as_slice(), &names_used),
|
||||
"sketches": kept_of(sketches.as_slice(), &sketches_used), "sheets": sheets,
|
||||
"validation": self.records.get("validation").cloned().unwrap_or(Json::Null),
|
||||
});
|
||||
// The check mode the results were evaluated under, as the model records it (a model
|
||||
// that records none stays without one: adopting it is refused either way).
|
||||
if let (Some(validation), Some(out)) = (self.records.get("validation"), records.as_object_mut()) {
|
||||
out.insert("validation".into(), validation.clone());
|
||||
}
|
||||
let kept: Vec<usize> = (0..self.bodies.len()).filter(|i| kernel_used.get(*i) == Some(&true)).collect();
|
||||
let bodies = kept.iter().filter_map(|i| self.bodies.get(*i).cloned()).collect();
|
||||
Some((SavedModel { records, bodies }, kept, used))
|
||||
|
||||
@@ -1087,7 +1087,10 @@ mod tests {
|
||||
.map(|(i, ms)| json!({"id": i + 1, "fingerprint": "0000000000000000", "ms": ms, "skipped": false, "state": i}))
|
||||
.collect();
|
||||
solidcraft_doc::SavedModel {
|
||||
records: json!({"features": features, "states": states, "model_bodies": records, "names": [{"faces": [], "info": []}], "sketches": [], "sheets": []}),
|
||||
records: json!({
|
||||
"features": features, "states": states, "model_bodies": records, "names": [{"faces": [], "info": []}], "sketches": [],
|
||||
"sheets": [], "validation": "each_feature",
|
||||
}),
|
||||
bodies,
|
||||
}
|
||||
}
|
||||
@@ -1113,6 +1116,7 @@ mod tests {
|
||||
let (states, kept, all, within) = thinned(40);
|
||||
assert_eq!((states, kept.len(), within), (vec![true; 4], 40, true));
|
||||
assert_eq!(all.records, model.records);
|
||||
assert_eq!(thinned(16).2.records["validation"], "each_feature", "the check mode it was evaluated under");
|
||||
// The final state and the slowest other (50 ms): the shared bodies count once, else
|
||||
// these two states would need 32 bodies' room.
|
||||
for bodies in [24, 31] {
|
||||
|
||||
Reference in New Issue
Block a user