@sheetwrite/corefunction
Build and validate one operation-phase snapshot without double-counting runtime observations.
- Package
@sheetwrite/core- Source
packages/core/src/resource-accounting.ts#L320
Declaration
function createRuntimeResourceSnapshot(input: { operation: RuntimeResourceOperationtype RuntimeResourceOperation =
| "startup"
| "scroll"
| "ingest"
| "edit"
| "dirty-clear"
| "formula-recompute"
| "auto-fit"
| "export"
| "snapshot"
| "persistence"
| "teardown";type RuntimeResourceOperation =
| "startup"
| "scroll"
| "ingest"
| "edit"
| "dirty-clear"
| "formula-recompute"
| "auto-fit"
| "export"
| "snapshot"
| "persistence"
| "teardown";type RuntimeResourceOperation =
| "startup"
| "scroll"
| "ingest"
| "edit"
| "dirty-clear"
| "formula-recompute"
| "auto-fit"
| "export"
| "snapshot"
| "persistence"
| "teardown";User-visible operation whose retained and transient resource costs are measured.API reference →; phase: RuntimeResourcePhasetype RuntimeResourcePhase =
"before" | "peak" | "settled" | "after-destroy";type RuntimeResourcePhase =
"before" | "peak" | "settled" | "after-destroy";type RuntimeResourcePhase =
| "before"
| "peak"
| "settled"
| "after-destroy";Measurement point within one resource-accounted operation.API reference →; wasm: StoreMemoryBreakdowninterface StoreMemoryBreakdown {
readonly protocolVersion: typeof STORE_MEMORY_PROTOCOL_VERSION;
readonly hashTableEstimateVersion: typeof STORE_MEMORY_HASH_ESTIMATE_VERSION;
readonly owners: readonly ResourceOwnerBytes[];
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
readonly wasmCommittedBytes: number | null;
readonly allocatorMarginBytes: number | null;
readonly unaccountedBytes: number;
}interface StoreMemoryBreakdown {
readonly protocolVersion: typeof STORE_MEMORY_PROTOCOL_VERSION;
readonly hashTableEstimateVersion: typeof STORE_MEMORY_HASH_ESTIMATE_VERSION;
readonly owners: readonly ResourceOwnerBytes[];
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
readonly wasmCommittedBytes: number | null;
readonly allocatorMarginBytes: number | null;
readonly unaccountedBytes: number;
}interface StoreMemoryBreakdown {
readonly protocolVersion: typeof STORE_MEMORY_PROTOCOL_VERSION;
readonly hashTableEstimateVersion: typeof STORE_MEMORY_HASH_ESTIMATE_VERSION;
readonly owners: readonly ResourceOwnerBytes[];
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
readonly wasmCommittedBytes:
number | null;
readonly allocatorMarginBytes:
number | null;
readonly unaccountedBytes: number;
}Decoded, fail-closed retained-memory ownership report from the WASM store.API reference →; jsOwners?: readonly ResourceOwnerBytesinterface ResourceOwnerBytes {
readonly owner: string;
readonly logicalBytes: number;
readonly allocatedBytes: number;
readonly entries: number;
readonly measurement:
| "exact-capacity"
| "hash-capacity-v1"
| "typed-array-byte-length"
| "utf16-upper-bound"
| "entry-count-only";
}interface ResourceOwnerBytes {
readonly owner: string;
readonly logicalBytes: number;
readonly allocatedBytes: number;
readonly entries: number;
readonly measurement:
| "exact-capacity"
| "hash-capacity-v1"
| "typed-array-byte-length"
| "utf16-upper-bound"
| "entry-count-only";
}interface ResourceOwnerBytes {
readonly owner: string;
readonly logicalBytes: number;
readonly allocatedBytes: number;
readonly entries: number;
readonly measurement:
| "exact-capacity"
| "hash-capacity-v1"
| "typed-array-byte-length"
| "utf16-upper-bound"
| "entry-count-only";
}Retained logical payload and allocated capacity attributed to one exclusive owner.API reference →[]; boundary?: readonly BoundaryOperationStatsinterface BoundaryOperationStats {
readonly operation: RuntimeResourceOperation;
readonly ffiCalls: number;
readonly jsToWasmBytes: number;
readonly wasmToJsBytes: number;
readonly largestTransferBytes: number;
readonly bulkCalls: number;
readonly scalarCalls: number;
}interface BoundaryOperationStats {
readonly operation: RuntimeResourceOperation;
readonly ffiCalls: number;
readonly jsToWasmBytes: number;
readonly wasmToJsBytes: number;
readonly largestTransferBytes: number;
readonly bulkCalls: number;
readonly scalarCalls: number;
}interface BoundaryOperationStats {
readonly operation: RuntimeResourceOperation;
readonly ffiCalls: number;
readonly jsToWasmBytes: number;
readonly wasmToJsBytes: number;
readonly largestTransferBytes: number;
readonly bulkCalls: number;
readonly scalarCalls: number;
}Fixed-cardinality boundary crossing counters for one operation.API reference →[]; runtime?: RuntimeMemoryObservationinterface RuntimeMemoryObservation {
readonly usedJSHeapSize: number | null;
readonly arrayBufferBytes: number | null;
readonly externalBytes: number | null;
readonly browserBackingStoreBytes: number | null;
}interface RuntimeMemoryObservation {
readonly usedJSHeapSize: number | null;
readonly arrayBufferBytes: number | null;
readonly externalBytes: number | null;
readonly browserBackingStoreBytes: number | null;
}interface RuntimeMemoryObservation {
readonly usedJSHeapSize:
number | null;
readonly arrayBufferBytes:
number | null;
readonly externalBytes:
number | null;
readonly browserBackingStoreBytes:
number | null;
}Available runtime-level memory observations, kept separate from retained owner totals.API reference →;}): RuntimeResourceSnapshotinterface RuntimeResourceSnapshot {
readonly schemaVersion: typeof RUNTIME_RESOURCE_SCHEMA_VERSION;
readonly operation: RuntimeResourceOperation;
readonly phase: RuntimeResourcePhase;
readonly wasm: StoreMemoryBreakdown;
readonly jsOwners: readonly ResourceOwnerBytes[];
readonly boundary: readonly BoundaryOperationStats[];
readonly runtime: RuntimeMemoryObservation;
readonly totals: {
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
};
}interface RuntimeResourceSnapshot {
readonly schemaVersion: typeof RUNTIME_RESOURCE_SCHEMA_VERSION;
readonly operation: RuntimeResourceOperation;
readonly phase: RuntimeResourcePhase;
readonly wasm: StoreMemoryBreakdown;
readonly jsOwners: readonly ResourceOwnerBytes[];
readonly boundary: readonly BoundaryOperationStats[];
readonly runtime: RuntimeMemoryObservation;
readonly totals: {
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
};
}interface RuntimeResourceSnapshot {
readonly schemaVersion: typeof RUNTIME_RESOURCE_SCHEMA_VERSION;
readonly operation: RuntimeResourceOperation;
readonly phase: RuntimeResourcePhase;
readonly wasm: StoreMemoryBreakdown;
readonly jsOwners: readonly ResourceOwnerBytes[];
readonly boundary: readonly BoundaryOperationStats[];
readonly runtime: RuntimeMemoryObservation;
readonly totals: {
readonly logicalLiveBytes: number;
readonly allocatedCapacityBytes: number;
};
}Complete retained-resource and boundary snapshot for one operation phase.API reference →