Skip to content

durable: service-result cleanups (settle output holder, typeName cost, fullTypeName size) #255

Open

Description

@reka18

What this is

Three cleanups in durable's service-result code, from the reviews of #235. None changes behavior.

  • Settle output through a shared holder. The JSON and Go type a settle decoded reach serviceStep through a mutable holder (settledJSON) that the result transform writes as a side effect. Each settle path, and Recover after replay, must remember to call take(), or the next step journals a previous settle's bytes. Passing the raw JSON and type back through the settle's own outcome would remove the coupling.
  • typeName runs on every settle. decodedAsRecorded and the live settle rebuild the full type spelling, a recursive reflect walk, once per Record or call. Caching it per reflect.Type (for example in a sync.Map) makes it one walk per type.
  • fullTypeName re-spells reflect type names. About 140 lines (chanTypeName, signatureName, structTypeName, interfaceTypeName, qualifiedName) re-implement reflect.Type.String with import paths, for result types a service rarely returns. Check whether PkgPath()+"."+Name() for named types, plus a smaller fallback, keeps the import-path tests from fix(durable): dispatch effects from Start, Tick and RunService #235 passing.

Relates to: #235

Activity

  1. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    Two more from a later review of #235, same kind:

    • Two passes over the tail. checkNotNewer and checkFormats each walk the whole tail and always run together (Recover, StateAt, Steps). One pass tracking the running maximum could refuse both a newer-than-supported format and a decrease, so a new reader can't call one and forget the other.
    • StartEffects built twice per checkpoint. parkedServices and endedServices each call h.inst.StartEffects() on every due checkpoint, under the step lock. Computing it once in appendStep and passing it to both would halve that.
  2. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    Three more from the next review of #235:

    • Copies of the recover-to-error guard. marshalEffect adds a fifth copy of the defer/recover pattern already in marshalPayload, errorMessage, decodePayload and applyEffect, and the copies already word the panic differently. decodedAsRecorded also repeats decodedAsPassed's nil and generic-form acceptance and its error text. A shared recoverErr helper, and one type check that takes a reflect.Type or a recorded name, would remove both.
    • Three constants for one format bump, and repeated locked-step shells. dispatchedStepsFormat, tickDriversFormat and decodedResultsFormat all mean format 2. lockedFireStep, lockedTickStep and lockedServiceStep repeat the same release and failOnPanic shell; one helper would do.
    • fooddelivery's float64 case. recordRefund type-switches on float64 to take the JSON-generic result, and int64(v) loses precision above 2^53. Registering DecodeAs[int64] for Refunded in the durable wiring would show the decoder path instead. That example module doesn't import durable today, so this needs a small rig change.
  3. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    Two more from the next review of #235:

    • Three copies of the step tail. tickStep, fireStep and serviceStep each take the actor-driven parent Fires, check for a context refusal, call recordParentFires, build the Record from drainClock plus those entries, and call recordStep. The context rule already differs: Tick and Fire use refusedByContext, RunService uses stepCanceled. One recordDriven(ctx, rec, effects, cancelCheck) helper would keep them in step.
    • Settled and parked as two maps. Every writer must update both (forgetServices, armMirror.forget, markSettled, armMirror.settle), and comments explain why they can't disagree. A single map[string]serviceMark shared by the Handle and the mirror would make that structural.
  4. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    Two more from the next review of #235:

    • absorbParentFire repeats absorbServices inline (forgetServices, then svc.Absorb). It could call the helper, so service bookkeeping lives in one place.
    • A dead marshal error path. recordServiceOutcome now wraps bytes that marshalPayload already produced and an error message already normalized, so its json.Marshal can't fail in practice. The same goes for parkResult's marshal. The h.fail branches after them in serviceStep and parkResult have no test and suggest failures that can't happen.
  5. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    One more from the next review of #235:

    • Live steps copy the whole dispatched set. Each live Fire, Tick or RunService with an effect reads the instance's whole lifetime dispatched set, and MemStore and FileStore copy it on every call, just to test one or two ids. Recover's cached copy (maps.Clone) adds another copy. The cost grows with the instance's life. A membership check for only the ids in the step, for example an optional DispatchedAmong(ctx, id, ids) on DispatchStore, would be far cheaper. That's new API, so it's a design question.
  6. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    One more from the last review of #235:

    • Recover repeats checkJournal inline. StateAt and Steps call checkJournal (checkNotNewer then checkFormats), while Recover calls the pair itself, with its own error prefix. A new format rule added to checkJournal would skip Recover. Have Recover call it (taking the verb for the message), and merge the two tail walks into one pass.
  7. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    From the review of slim #235 (fe94eea):

    • One name per journal format. tickDriversFormat and dispatchedStepsFormat are both 2 and gate the same bump; one constant documenting both behaviors avoids splitting the replay and dispatch gates by accident. errorMessage is now only called by normalizedErrorMessage and can fold into it.
    • absorbParentFire and absorbSettle re-spell the forget, timer and service order that absorbDrivers already has; three copies can drift from replayArm and replayRunners.
  8. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    From the second review of slim #235 (a2bd493):

    • Five near-copies of the absorb sequence. absorbDrivers, absorbSettle, absorbParentFire, absorbRunners and absorbServices each repeat forget settles, arm timers, hand to services and hand to actors, with a step left out or reordered; replayArm and replayRunners repeat it on replay. One absorb that takes which drivers to feed would keep the order in one place.
    • hasSpawnEffect repeats the SpawnActor scan that declaredActors and parentFires.attempt already do.
  9. reka18 commented on Nov 17, 2026

    @reka18
    ContributorAuthor

    From the fourth review of slim #235 (c393fd3):

    • absorbActors feeds the actor system one effect at a time, taking the collector lock and calling AbsorbFor for every effect, including ones the actor system ignores (ScheduleAfter, StartService, domain effects). Skipping non-actor effects first would avoid that.
    • absorbRunners is a one-line wrapper used only by absorbDrivers.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions