Table of Contents

Class FenceCostModel

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Per-stage cost coefficients used by the fence work-planner to size chunks. Each value scales the corresponding work-hint (migration count, dirty-cluster count, shadow-entry count, spatial-entry count) into a unitless cost figure that the planner bin-packs across workers.

Unit: 1 cost unit ≈ 1 µs of single-worker wall time. Default is calibrated against AntHill traces (migration ≈ 33 µs/entity, AABB recompute ≈ 2.4 µs/cluster). Shadow / Spatial coefficients are placeholders pending measurement. Other workload profiles (shadow-heavy SV writes, sparse spatial) should override these via FenceCostModel; the defaults will load-balance against ratios that don't match your workload, leading to less optimal chunk packing.

public sealed record FenceCostModel : IEquatable<FenceCostModel>
Inheritance
FenceCostModel
Implements
Inherited Members

Constructors

FenceCostModel(float, float, float, float)

Per-stage cost coefficients used by the fence work-planner to size chunks. Each value scales the corresponding work-hint (migration count, dirty-cluster count, shadow-entry count, spatial-entry count) into a unitless cost figure that the planner bin-packs across workers.

Unit: 1 cost unit ≈ 1 µs of single-worker wall time. Default is calibrated against AntHill traces (migration ≈ 33 µs/entity, AABB recompute ≈ 2.4 µs/cluster). Shadow / Spatial coefficients are placeholders pending measurement. Other workload profiles (shadow-heavy SV writes, sparse spatial) should override these via FenceCostModel; the defaults will load-balance against ratios that don't match your workload, leading to less optimal chunk packing.

public FenceCostModel(float MigrationCost, float AabbCost, float ShadowCost, float SpatialCost)

Parameters

MigrationCost float
AabbCost float
ShadowCost float
SpatialCost float

Fields

Default

Default coefficients, calibrated against AntHill traces: migration ≈ 33.3 µs/entity, AABB recompute ≈ 2.4 µs/cluster. Shadow and Spatial coefficients are placeholders (1.0) pending measurement — override them for shadow-heavy or spatial workloads.

public static readonly FenceCostModel Default

Field Value

FenceCostModel

Properties

AabbCost

public float AabbCost { get; init; }

Property Value

float

EntityMapUpdateCost

Cost per staged EntityMap location patch, in the planner's arbitrary units. Seeded from step 7's measurement — ~40 ns/entity for the serial apply, against ~11 ns for an index update — and refined at runtime by Typhon.Engine.Internals.LiveFenceCostModel like every other coefficient.

public float EntityMapUpdateCost { get; init; }

Property Value

float

FinalizeEmitCost

µs per dirty cluster of Finalize's WAL emit when it runs as slices (#889). Seeded from the measurement that motivated the slicing — 0.6 ms for ~2 000 dirty clusters of 64 entities on Matrix M — and refined at runtime by Typhon.Engine.Internals.LiveFenceCostModel like every other coefficient.

public float FinalizeEmitCost { get; init; }

Property Value

float

IndexUpdateCost

µs per staged index value update, for the IndexMassUpdate phase (#872 step 6).

public float IndexUpdateCost { get; init; }

Property Value

float

Remarks

Three orders of magnitude below MigrationCost, which is exactly why it needs its own coefficient. The phase's first implementation reused MigrationCost — ≈33 µs, the cost of MOVING an entity — to price an operation measured at 0.055-0.077 µs. Nothing mis-computes, but every index batch then looks enormously expensive to the planner, so ComputeMaxChunks's floor(totalCost / MinChunkCostUs) term saturates at its 2 × workerCount × oversubscription cap for any batch at all, and the phase splits into the smallest chunks it is allowed to — precisely the regime the 200 µs floor exists to avoid.

Seeded at 0.06 from #872 step 6's --fence-parallel measurement: 10 000 uniform updates on a 1 M-entry tree at 55-77 ns each, depending on how many leaves the batch touches. Calibrated live from the phase's own wall time when AdaptiveFenceCost is on.

MigrationCost

public float MigrationCost { get; init; }

Property Value

float

ShadowCost

public float ShadowCost { get; init; }

Property Value

float

SpatialCost

public float SpatialCost { get; init; }

Property Value

float

Methods

Deconstruct(out float, out float, out float, out float)

public void Deconstruct(out float MigrationCost, out float AabbCost, out float ShadowCost, out float SpatialCost)

Parameters

MigrationCost float
AabbCost float
ShadowCost float
SpatialCost float

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(FenceCostModel?)

public bool Equals(FenceCostModel? other)

Parameters

other FenceCostModel

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(FenceCostModel?, FenceCostModel?)

public static bool operator ==(FenceCostModel? left, FenceCostModel? right)

Parameters

left FenceCostModel
right FenceCostModel

Returns

bool

operator !=(FenceCostModel?, FenceCostModel?)

public static bool operator !=(FenceCostModel? left, FenceCostModel? right)

Parameters

left FenceCostModel
right FenceCostModel

Returns

bool