Skip to content

No idle grace period before a shared instance is destroyed #220

Description

@Yaraslaut

Part of #198 (virtual-actor/actor-sharding survey).

Observation

morph destroys a shared instance immediately at zero attachments, with no idle grace period and no persistence provider — whatever the instance hydrated into memory is discarded the instant the last handler detaches, and the next attach re-hydrates from scratch. Every comparable virtual-actor/actor-sharding system instead keeps an entity resident for some time past its last caller: Orleans defaults CollectionAge to 15 minutes, Akka/Pekko Cluster Sharding defaults idle passivation to 2 minutes, and Cloudflare Durable Objects hibernate "several seconds" after going idle. All three treat minutes-to-seconds-scale residency as the default, not an exotic feature.

The case this bites hardest: a GUI client that reconnects (morph::offline's reconnect path is a first-class morph feature). A single client's connection flapping tears down the shared instance on disconnect and pays full re-hydration cost on the very next attach, even though no other client ever stopped wanting it.

Status: already an explicit deferral in the spec

docs/spec/core/shared_instances.md:455,543 already defers this: "An optional idle grace period … is not part of this work. Default behaviour is immediate destruction at zero." This issue does not propose implementing a grace period now — it re-raises the deferral with the additional evidence that minutes-scale residency is the industry default across Orleans/Akka/Durable Objects, in case that shifts the priority of revisiting it. Nothing has fired the trigger yet; this is filed as a parked marker with an explicit re-entry condition, the same shape as #116-#119 (children of #115).

Revisit only if

Re-hydration cost or reconnect churn shows up as an actual problem in a real example or application — e.g. a model whose hydration does non-trivial I/O (a DB read, a remote call) observed to reconnect/flap often enough that repeated full re-hydration is measurably expensive, or a user-visible report of state loss / latency spikes tied to attach-count transitions through zero.

Verification status

Read directly against master 42deb96: docs/spec/core/shared_instances.md Limitations ("No idle deactivation. Zero attachments destroys immediately; there is no keep-alive, no LRU, no eviction policy") and the lifetime section (:455, :543) documenting the deferral. Comparison figures (Orleans 15 min, Akka 2 min, Durable Objects seconds) are read from each project's own published documentation, not independently benchmarked — see #198 for full citations.

Origin

Surfaced in #198 (survey of morph's instance model against virtual-actor/actor-sharding systems) as "candidate gap G1." The triage comment on #198 judged this the one gap that genuinely matches the #115-sibling "speculative, park with a trigger" shape, since the spec already defers it and no re-entry condition has fired.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreSubsystem: coreenhancementNew feature or requesttriage: parkedDeferred with an explicit re-entry condition

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions