Skip to content

Perf(shape): derive transition-map keys from one secure realm seed #662

Description

@chrisbbreuer

Parent: #479
Related: #461, #493

Profile finding

A fresh current-main five-second sample of 30,000 production Context create/destroy iterations attributes the leading engine leaf to Shape transition construction: 257 samples in Shape.transitionFromState, 147 in transition publication, and 158 top-of-stack samples in the platform AES path reached by repeated secure-random requests. Every Shape currently requests a new 128-bit SipHash seed when its first transition map is created, even though all Shapes already share one realm lifetime and allocator.

This is diagnostic attribution, not a public timing claim.

Goal

Request secure entropy once for each root Shape, then derive a distinct keyed SipHash seed for every transition map from that realm-owned secret and a monotonic per-realm domain value. Preserve the current collision-resistant expected search bound without process-global mutable state, cross-realm sharing, predictable public keys, or entropy fallbacks.

Scope

  • Add a root-owned transition-key source whose lifetime exactly matches the Shape tree.
  • Fail Context creation closed when the single secure seed cannot be obtained, matching the current security contract.
  • Derive a separate key for each transition map with explicit domain separation and thread-safe unique allocation under parallel Shape publication.
  • Keep transition lookup, immutable names, release publication, per-Shape writer serialization, exact convergence, and arena teardown unchanged.
  • Add deterministic fixed-seed derivation tests plus concurrent uniqueness/publication coverage.
  • Measure the exact parent with the Bench: publish cold context lifecycle phase and retention evidence #661 no-evaluation lifecycle profile and a warm property/shape control; retain exact checksums, finalizer reconciliation, RSS plateau, and Test262 behavior.

No-workaround rules

  • No constant or public seed, weak PRNG, entropy-error fallback, process-global key/counter, shared mutable Shape tree, skipped transition caching, disabled locking, or benchmark-only fast path.
  • No changes to stacks, queues, jobs, Promise, Worker, or Map/Set iterator surfaces.

Acceptance

  • One secure entropy request initializes each root Shape; every transition-map key is uniquely derived within that realm.
  • Fixed-seed tests prove deterministic domain separation and distinct adjacent keys.
  • Concurrent transition publication preserves exact same-name convergence, logarithmic keyed lookup structure, and race-free unique key allocation.
  • Exact-parent cold lifecycle evidence shows the entropy/crypto hotspot removed with identical checksums, finalizers, and bounded retained RSS.
  • Warm shape/property controls do not regress materially.
  • Focused Shape, Context, no-GIL/TSan, full unit, and relevant Test262 gates pass with zero semantic flips.

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