Files
Fr0zkaandClaude Opus 5.5 4e64b75044 feat(core): slab + sparse motifs, slice 1 -- flat field, monolith, platform at 0.52 s (L56); research R25
Motif vocabulary v3: version-1 records keyed by (seed, strate, stable ID) with route keepouts, band
clearance and pairwise spacing. A rounded capped-cylinder monolith (r 1.4 m, 24 m tall) and a rounded-box
plinth, smooth-unioned into a flatField floor with a 0.55 m geometric rounding (measured fillets 0.73-1.17 m).
Exact radial/box interval bounds, a BVH, isTileShapeFree aware (0 brute-force misses, false-proof controls
rejected). Final-field route passes; whole-surface audit covers foot, cap and platform edges. Cold whole
view 0.524 s. Owner world unchanged. fast/medium/full PASS (Clang and GCC).
Research R25 (self-checked): FloatingIslands LOD0 column cache conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-10-25 07:47:15 +01:00

6.6 KiB
Raw Permalink Blame History

R25 — Why FloatingIslands’ LOD0 grid is expensive

Cache mechanics

IslandColumnCache in FloatingIslandsInternal.h is a four-way set-associative cache with 2,048 sets (8,192 entries) per worker. It hashes recipe and plan identity, island ID, seed, and integer X/Y. Equality also checks the island’s geometry parameters. The key deliberately has no Z or LOD.

On a miss, it uses the first invalid way; once the set is full, it replaces the way selected by bits of the key hash. It has no LRU policy. The worker cache is allocated lazily on first use and lasts until that thread exits (ThreadLocalStorage.h). The shared second-level cache has 16,384 four-way sets (65,536 entries); once full, it replaces ways round-robin (SharedColumnCache.h).

A FI “column” here is per-island XY math, not a stored density column or heightfield: delta X/Y, radius, angle, lobe phase, and top surface. The SDF still evaluates its Z-dependent shape, roots, detail, and connectors at each sample (IslandDensity).

The grid normally scans XY rows plane by plane across Z (mesher traversal). Each XY/island key is reused vertically, but the full XY plane intervenes. Meanwhile, worker caches persist across tiles, and both cache levels have bounded, set-associative capacity. When a miss finds all four ways occupied, the counter records a conflict replacement. Thus, conflicts being nearly equal to misses means the caches were already warm and their selected sets were full; it does not by itself prove a direct-map aliasing stride. The code uses four ways, and adding Z to the key would defeat the intended vertical reuse.

Cost split

L55 assigns 27.61 worker-s to FI LOD0 grid work. The cache recorded 62.26M local requests: 34.58M hits and 27.68M misses. Of those misses, 23.95M hit the shared cache; only 3.73M caused a shared compute. The 151 ms of measured shared-lock wait is about 0.55% of grid time. It does not include the cost of local probes, shared atomic reads, hashing, or comparisons, so the counters cannot give a reliable cache-time percentage.

The field path is also substantial: L55’s plan has four islands and three connectors. RootCount is five, so a full scan evaluates up to 20 root-lobe SDFs per density query, plus island contours and connector fields (root count and scan, field composition). The contour warp uses three Z-varying angular sine terms; there is no separately named helix evaluator in this path (LobeOffsetWithPhase).

There is no timer splitting field arithmetic from cache probes. The supported estimate is that cache recomputation and lock waiting are a small part of the cost, while the 62M lookup path may still be material. The code’s repeated root and feature evaluation is expensive, but an exact time fraction needs a direct measurement.

Ranked fixes

The 37% LOD0 target requires saving about 10.2 worker-s. These are ordinal estimates; no A/B timing supports precise savings yet.

Rank Fix Expected saving Risk and exactness
1 Use tile-scoped per-island candidates and tighten their bounds. The four-island plan marks candidate evaluation “not useful,” so sampling falls back to the full scan even though FieldDensityForTile has ordered group bounds (tile-list hint). Very high: a skipped group avoids five root SDFs and its feature work. Medium risk; exact with conservative bounds and canonical composition order.
2 Refine interval proofs adaptively around uncertain blocks. Current 8-cell proofs skip 892,416 air cells—about 6.2% of LOD0 candidates—and no solid cells. Large blocks and conservative bounds are plausible reasons for the low skip count; the logs do not report verdicts by feature or bound. High if more empty cells can be certified. Medium risk; exact when every skipped region has a valid sign proof.
3 Evaluate coarse per-island bounds, then refine near the surface. High potential for avoiding full-resolution work in air. High risk if coarse values become final interpolated densities; exact only when they guide conservative proofs and all uncertain samples are refined.
4 Replace hashed column lookup with a tile-local XY table, or increase local set count/associativity. The 27.68M local misses currently trigger shared lookups, most of which are shared hits. Medium: reduces lookup/hash/atomic traffic, not the root and connector evaluations. Low risk; exact. A direct XY table also matches what the cached values actually represent.
5 Precompute per-island distance volumes. Potentially high if reused across many tiles or LODs. High memory and setup cost; exact at stored lattice points if canonical values are retained, approximate under interpolation.
6 Add a per-tile 3D cache of island-local values. Low to medium for this grid pass: each density-grid point is generally sampled once, and the mesher already stores final densities. Exact if values are stored unchanged; adds memory and pays off only where other passes reuse those samples.

Sparse 3D blocks are a well-established fit for localized, high-frequency volume data; OpenVDB documents hierarchical sparse storage and active narrow bands. That supports the structure as a design option, not a speedup prediction for this workload. OpenVDB overview

Confirming measurement

Add sampled cycle timings for the local probe, shared lookup, shared compute, and the island/root/connector field work, reported per tile and LOD. Pair those with set-occupancy or eviction-reuse-distance counts. This will show whether cache probes or SDF arithmetic dominate the 27.61 worker-s, and whether the full-set replacements evict keys needed again in the next Z plane.

Read-only review complete; no scripts, tests, builds, binaries, or source edits were made.