Stop retrying a provider that took the app down
The probe runs in the app's process, and a provider can fail by aborting rather than by returning an error — XNNPACK did on SCRFD. A rung that does that once would do it on every launch, before the first photograph is on screen. Every session build above the CPU, the probe's and each background compile's, now writes what it is attempting to `attempt` in the cache directory first and removes it after. After two launches in a row that died inside the same attempt it is refused and recorded — a rung in `failed`, an engine in the new `refused` — until the fingerprint changes. Two, not one, because quitting during a TensorRT compile leaves the same file.
This commit is contained in:
@@ -90,12 +90,27 @@ pub fn run() {
|
||||
Source::Bytes(b) => (b.to_vec(), format!("embedded {role:?}")),
|
||||
};
|
||||
let key = key(rung, &bytes);
|
||||
if state().lock().unwrap().cache.compiled.contains(&key) {
|
||||
continue;
|
||||
{
|
||||
let s = state().lock().unwrap();
|
||||
if s.cache.compiled.contains(&key) || s.cache.refused.contains(&key) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
log::info!("inference: compiling {name} for {}", rung.label());
|
||||
let started = std::time::Instant::now();
|
||||
match crate::session::build(rung, role, &bytes, &cfg) {
|
||||
let built = match crate::probe::attempt(&cfg, &key, || {
|
||||
crate::session::build(rung, role, &bytes, &cfg)
|
||||
}) {
|
||||
Ok(built) => built,
|
||||
Err(_) => {
|
||||
// Refused: the process died inside this compile before.
|
||||
let mut s = state().lock().unwrap();
|
||||
s.cache.refused.insert(key);
|
||||
crate::probe::write_cache(&s.config, &s.cache);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
match built {
|
||||
Ok(session) => {
|
||||
drop(session);
|
||||
let mut s = state().lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user