mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-25 18:46:56 +08:00
Adds two new fields to CacheContext that lets external CacheProvider implementations make cost-aware caching decisions: - compute_time_ms — wall-clock for this node's get_output_data call - compound_compute_ms — own time + sum of all ancestor compute times The executor times each call to get_output_data and records it on the output cache. _build_context walks the dynprompt graph from the target node to sum ancestor times (cached ancestors contribute 0, a correct lower bound for what a future hit on this node would save). Why: a small leaf-output downstream of an expensive chain is worth caching even though the leaf itself is cheap — because a future hit prunes the whole subgraph. A pure leaf with no expensive ancestors is not worth the round-trip. Providers couldn't distinguish these without the timing data, leading to size-based heuristics that systematically mis-cached the long tail. Backward-compatible: new fields default to 0.0, so existing providers keep working unchanged. Providers that opt in can read context.compound_compute_ms in should_cache() to gate on real work-saved.