Prewarm LaTeX format and cache verified project preparation artifacts
This commit is contained in:
1 parent
fdd327eb01
commit
c1742e1c10
10 files changed
+668
-28
No files matched your search
@@ -1,7 +1,11 @@
|
||||
use super::{InputProfile, OpeningEditor, fs, json, projects::ProjectStore, reply, stage_sources};
|
||||
use super::{
|
||||
InputProfile, NativeCompiler, OpeningEditor, fs, json, projects::ProjectStore, reply,
|
||||
stage_sources,
|
||||
};
|
||||
use std::{
|
||||
io::{ErrorKind, Read},
|
||||
path::{Path, PathBuf},
|
||||
time::Instant,
|
||||
};
|
||||
use tiny_http::Request;
|
||||
|
||||
@@ -14,6 +18,7 @@ pub(super) struct Library {
|
||||
manifest: PathBuf,
|
||||
runs: PathBuf,
|
||||
profile: InputProfile,
|
||||
compiler: NativeCompiler,
|
||||
}
|
||||
|
||||
impl Library {
|
||||
@@ -37,9 +42,33 @@ impl Library {
|
||||
manifest,
|
||||
runs,
|
||||
profile,
|
||||
compiler: NativeCompiler::default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn prewarm_format(&self) {
|
||||
let compiler = self.compiler.clone();
|
||||
let format = self.format.clone();
|
||||
let _ = std::thread::Builder::new()
|
||||
.name("texrra-prewarm-format".into())
|
||||
.spawn(move || {
|
||||
let trace = std::env::var_os("TEXRRA_EDITOR_PREPARATION_TRACE")
|
||||
.is_some_and(|value| value == "1");
|
||||
let started = Instant::now();
|
||||
let result = compiler.prewarm_format(&format);
|
||||
if trace {
|
||||
eprintln!("Texrra editor preparation {}", json!({
|
||||
"stage": "prewarm-format",
|
||||
"ms": started.elapsed().as_secs_f64() * 1000.0,
|
||||
"ok": result.is_ok(),
|
||||
}));
|
||||
}
|
||||
if let Err(error) = result {
|
||||
eprintln!("Editor format prewarm: {error}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn list(&self, request: Request) {
|
||||
match self.store.list() {
|
||||
Ok(projects) => reply(request, 200, json!({"projects": projects})),
|
||||
@@ -127,7 +156,9 @@ impl Library {
|
||||
let cache = super::preview_cache::PreviewCache::for_project(
|
||||
&self.runs, &info.id, &run, &staged, &self.format, &self.manifest,
|
||||
);
|
||||
OpeningEditor::start(info.id, run, staged, cache)
|
||||
let compiler = self.compiler.new_session_sharing_format()
|
||||
.with_automatic_entry_checkpoints();
|
||||
OpeningEditor::start(info.id, run, staged, cache, compiler)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user