mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-19 16:45:28 +00:00
Watch Folder renders take the host's memory budget; docs and test comment (#3941 review)
This commit is contained in:
1 parent
0d9c69563f
commit
98ada1e8ff
5 files changed
+59
-6
No files matched your search
@@ -40,6 +40,21 @@ fn tmp(name: &str) -> PathBuf {
|
||||
canonical(&d).unwrap_or(d).join(name)
|
||||
}
|
||||
|
||||
/// #3941: a command-line session reads the system's memory at start, so its caches share the
|
||||
/// budget of the installed RAM (as in the desktop app), not the budget for unknown RAM.
|
||||
#[test]
|
||||
fn the_caches_follow_the_installed_ram() {
|
||||
let Some(memory) = effectcraft_engine::sysinfo::memory() else {
|
||||
eprintln!("the system's memory can't be read here: not checked");
|
||||
return;
|
||||
};
|
||||
let v = ok_json(&["exec", "help.systemReport", r#"{"quiet":true}"#, "--empty"]);
|
||||
let reduced = v["caches"]["reduced"].as_bool().unwrap();
|
||||
let want = effectcraft_engine::prefs::Prefs::default().memory_budget(Some(memory), reduced).bytes;
|
||||
let gb = |b: usize| format!("{:.1} GB", b as f64 / (1u64 << 30) as f64);
|
||||
assert_eq!(v["caches"]["budget"], gb(want), "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn info_and_commands() {
|
||||
let v = ok_json(&["info"]);
|
||||
|
||||
@@ -65,6 +65,9 @@ fn render_project(host: &Session, path: &Path) -> Value {
|
||||
s.exporter = host.exporter.clone();
|
||||
s.accel = host.accel.clone();
|
||||
s.prefs = host.prefs.clone();
|
||||
// Its Render Queue caches take the host's memory budget (#3941), which follows its reading.
|
||||
s.sys_memory = host.sys_memory;
|
||||
s.memory_low = host.memory_low;
|
||||
let result = (|| -> std::result::Result<Value, String> {
|
||||
s.execute("file.open", json!({"path": name})).map_err(|e| e.to_string())?;
|
||||
let queued = s.project.render_queue.iter().filter(|i| i.render && i.status == RenderStatus::Queued).count();
|
||||
|
||||
@@ -309,8 +309,8 @@ fn a_queue_run_keeps_its_jobs_warm() {
|
||||
|
||||
#[test]
|
||||
fn render_queue_runs_and_one_off_exports_follow_the_memory_budget() {
|
||||
// #3941: a Render Queue run's two layer caches held 512 MiB together and a one-off export's
|
||||
// 512 MiB each, whatever the memory budget. Both follow the session's budget now.
|
||||
// #3941: a Render Queue run's two layer caches and a one-off export's held 512 MiB each
|
||||
// (1 GiB together), whatever the memory budget. Both follow the session's budget now.
|
||||
type Seen = (Option<(usize, usize)>, Option<usize>);
|
||||
struct Budgets(Mutex<Vec<Seen>>);
|
||||
impl Exporter for Budgets {
|
||||
|
||||
@@ -58,6 +58,39 @@ fn watch_folder_renders_queued_projects_and_writes_status() {
|
||||
assert!(host.execute("file.watchFolder", json!({"folder": "/no/such/folder"})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_watch_folder_render_takes_the_hosts_memory_budget() {
|
||||
// #3941: the Watch Folder renders each project in a session of its own, which had no memory
|
||||
// reading: its Render Queue caches took the budget for unknown RAM, not the host's.
|
||||
use crate::{ExportJob, ExportResult, Exporter};
|
||||
use effectcraft_project::render_queue::OutputFormat;
|
||||
struct Budgets(std::sync::Mutex<Vec<Option<usize>>>);
|
||||
impl Exporter for Budgets {
|
||||
fn formats(&self) -> Vec<OutputFormat> {
|
||||
OutputFormat::ALL.to_vec()
|
||||
}
|
||||
fn export(&self, job: &ExportJob, _: &mut dyn FnMut(u64, u64) -> bool) -> Result<ExportResult, String> {
|
||||
self.0.lock().unwrap().push(job.caches.map(|c| c.gpu.budget()));
|
||||
Ok(ExportResult { path: job.path.to_string(), ..Default::default() })
|
||||
}
|
||||
}
|
||||
let dir = out_dir("watch-folder-budget");
|
||||
let ex = Arc::new(Budgets(Default::default()));
|
||||
let mut a = Session { exporter: Some(ex.clone()), ..Default::default() };
|
||||
a.execute("comp.new", json!({"name": "Shot", "width": 32, "height": 32, "frameRate": 10, "duration": 0.5})).unwrap();
|
||||
a.execute("renderQueue.add", json!({})).unwrap();
|
||||
a.execute("file.saveAs", json!({"path": dir.join("a.ecproj").to_string_lossy()})).unwrap();
|
||||
|
||||
let mut host = Session { exporter: Some(ex.clone()), ..Default::default() };
|
||||
// A 64 GB machine: 46.4 GB with the default reserve.
|
||||
host.take_memory_reading(Some(crate::sysinfo::SysMemory { total: 64 << 30, available: 48 << 30 }));
|
||||
let budget = host.export_cache_budget();
|
||||
assert_ne!(budget as u64, crate::prefs::FALLBACK_MEMORY_BUDGET);
|
||||
host.execute("file.watchFolder", json!({"folder": dir.to_string_lossy()})).unwrap();
|
||||
host.execute("file.watchFolder", json!({"stop": true})).unwrap();
|
||||
assert_eq!(*ex.0.lock().unwrap(), vec![Some(budget)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vanishing_point_import_is_disabled_with_a_reason() {
|
||||
let mut s = Session::default();
|
||||
|
||||
+6
-4
@@ -192,13 +192,15 @@ Commands (CLI, MCP, control channel):
|
||||
cache's reserve free on their disk; earlier sessions' copies are adopted. The Disk page shows
|
||||
the local copies, what is queued and being copied, and the network locations
|
||||
- `memory.ramReservedGb`: RAM Reserved for Other Applications, the one memory setting (After
|
||||
Effects has a setting of this name too). EffectCraft's big caches (processed layers, decoded
|
||||
footage frames, decoded OpenEXR planes, RAM preview frames, and the disk cache's write queue)
|
||||
share one budget: 80 % of the installed RAM left after the reserve. The other 20 % is room for
|
||||
Effects has a setting of this name too). EffectCraft's big caches (processed layers, also those
|
||||
of exports and Render Queue runs, decoded footage frames, decoded OpenEXR planes, RAM preview
|
||||
frames, and the disk cache's write queue) share one budget: 80 % of the installed RAM left
|
||||
after the reserve. The command-line tool and its MCP server read the installed RAM once at start
|
||||
(with the default reserve: they don't read the app's settings). The other 20 % is room for
|
||||
EffectCraft's own working memory (decoders, render buffers, undo, GPU staging, the interface).
|
||||
With the default 6 GB reserved that is 8.0 GB on a 16 GB machine, 46.4 GB on 64 GB and 97.6 GB
|
||||
on 128 GB. The budget is at least 192 MB for all caches together; while the installed RAM is
|
||||
unknown (a sandbox, the CLI, or the desktop before its first reading) it is 5 GB, in the browser 3.5 GB
|
||||
unknown (a sandbox, or the desktop before its first reading) it is 5 GB, in the browser 3.5 GB
|
||||
(with the RAM preview at most 3 GB there). No cache has a share of its own: when they
|
||||
hold more than the budget together, the memory accountant frees the least valuable data first,
|
||||
whichever cache holds it, down to 90 % of the budget. An item's value is what it would cost to
|
||||
|
||||
Reference in new issue
Block a user