无历史重放的持久化执行
Durable execution without history replay

原始链接: https://trigora.dev/blog/durable-execution-without-history-replay/

传统的持久化执行系统通过重放历史执行日志来恢复程序状态。虽然这种方法行之有效,但随着程序运行时间延长和历史记录积累,该过程会变得愈发缓慢。 为了解决这一问题,作者提出了“透明延续检查点”(Transparent Continuation Checkpointing,简称 TCC)。TCC 不再重放过去,而是在持久化边界处捕获程序的“实时延续”——即程序向前推进所需的精确控制状态。一旦发生故障,运行时会直接恢复该状态,使程序能够立即恢复运行。 初步评估显示,TCC 显著提升了恢复的扩展性。传统的基于重放的系统会随着执行历史的增长而导致延迟增加,而 TCC 无论过去的运行深度如何,都能保持近乎恒定的亚毫秒级恢复时间。 TCC 目前仍处于原型阶段,正在以 **Trigora** 为项目名称进行开发,专门针对长期运行的动态 AI 智能体。作者认为,通过将恢复过程与执行历史解耦,TCC 为下一代复杂且长寿命的软件提供了一种更高效的底层基础,尽管在版本控制、可移植性和生产级基础设施方面仍有挑战待解决。

这篇 Hacker News 讨论探讨了“持久化执行”(durable execution)这一日益发展的范式,它允许长时间运行的进程在系统崩溃和重启后依然能够存续。 主要观点包括: * **重放与快照:** 目前行业标准(如 Temporal)依赖于事件溯源(历史重放),这避免了序列化整个对象图的复杂性。然而,重放可能会变得缓慢且难以管理。参与者建议,未来的系统可能会结合快照与重放技术,并可能利用 WebAssembly (WASM) 来更高效地捕获程序状态。 * **关于“流行语”的争论:** 怀疑论者认为“持久化执行”只是现有模式的一个笼统称呼。支持者则反驳称,它提供了一种强大的抽象(等同于延续性),通过使代码能够抵御基础设施故障而无需自定义重试逻辑,从而简化了分布式系统。 * **实际落地:** 开发人员分享了构建持久化执行框架的经验,指出它通常是在处理极端规模和可靠任务处理需求时自然产生的。成功的实现方案高度依赖于幂等性以及严格的架构约束(例如将命令与查询分离),以确保重复运行代码能产生一致的结果。 * **人工智能应用:** 人们越来越关注如何利用这些模型来提高智能体 LLM 工作流程的可靠性和可复现性。
相关文章

原文

Most durable execution systems recover by replaying retained execution history. After a worker fails, a fresh worker loads the history and re-executes the program until it reconstructs the current position.

This is a useful model. It provides durable progress while allowing workers to remain ephemeral. But it also makes accumulated history part of the recovery path.

That tradeoff becomes more noticeable for programs that operate for hours or days, call many tools, wait for external events, create child executions, and change direction dynamically. Long-running agents increasingly have this shape.

I’ve built and evaluated a different recovery primitive: checkpointing the program continuation instead of reconstructing it from history.

Transparent Continuation Checkpointing

I call the approach Transparent Continuation Checkpointing, or TCC.

At durable boundaries, the compiler and runtime capture the live continuation: the control state required for the program to continue from its current position. When execution resumes after a failure, the runtime loads the committed continuation and restores the program directly.

History replay reconstructs the current position. TCC restores the committed continuation and resumes.

The distinction is:

History replay

Load retained history → re-execute the prefix → reconstruct the current position

TCC

Load committed continuation → restore live execution state → resume

External effects remain explicit durable operations. Completed durable work is not repeated after recovery, and unsupported language constructs fail during compilation rather than producing ambiguous runtime behaviour.

The current prototype supports durable effects, external waits and events, child executions, cancellation, structured concurrency, and crash recovery.

What changes

TCC does not make recovery constant-time. Recovery remains sensitive to the size and structure of the live continuation.

The intended change is in what recovery depends on.

With replay, recovery is influenced by the execution history retained to reconstruct the current position. With TCC, recovery is influenced primarily by the state the program still needs.

A program that has performed ten thousand operations but retains a small live continuation should not necessarily become harder to recover simply because its past is long.

Preliminary evaluation

I ran a controlled comparison in which live continuation state remained approximately fixed while durable-boundary depth increased from 10 to 1,000.

Recovery latency vs prior durable-boundary depth 1ms 10ms 100ms 1s 10 100 1000 durable-boundary depth
TCC recovery Temporal reconstruction Controlled evaluation · ~4 KB live state

In that evaluation, TCC recovery remained between approximately 0.6 and 0.9 milliseconds. Fresh-worker replay reconstruction in the evaluated Temporal baseline increased from approximately 61 milliseconds to 1.7 seconds.

Worker creation was excluded, the live state was approximately 4 KB, and these results should not be interpreted as a general production-speedup claim. They demonstrate a difference in recovery scaling under the tested conditions, not that every TCC workload will outperform every replay-based system.

Methodology and limitations

I have also exercised the execution semantics across 50,000 generated cases, with no observed semantic failures in the evaluated subset.

What remains difficult

Turning the prototype into production infrastructure still involves substantial work:

  • Portable continuation representation
  • Program and checkpoint versioning
  • Efficient handling of larger live states
  • Durable storage and commit protocols
  • Operational observability
  • Compatibility across language frontends
  • Framework integrations
  • Long-running correctness and failure testing

There are also design questions around checkpoint retention, branching from previous continuations, migration between runtime versions, and how much of the execution representation should remain stable across languages.

I’m building Trigora around this model, initially for long-running AI agents. The broader question is whether continuation-based recovery can provide a better execution substrate for dynamic, long-lived software.

The architecture, semantics, benchmark setup, and current limitations are described in more detail in the technical paper. You can also see continuation recovery in action in a controlled demonstration of the current TCC compiler/runtime.

I’d be particularly interested in criticism from people who have worked on workflow engines, compilers, checkpointing systems, or distributed runtimes.

联系我们 contact @ memedata.com