Repository navigation
impr: Better d.memoryLayoutOf cache - #3261
cieplypolar wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.91, 1.84, 3.59, 6.26, 6.47, 9.26, 23.00, 24.03]
line [0.84, 1.73, 3.83, 5.77, 6.92, 10.18, 22.26, 22.96]
line [0.92, 1.82, 4.05, 5.72, 6.43, 10.97, 21.32, 23.15]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.24, 0.48, 0.60, 0.80, 1.04, 1.10, 1.27, 1.46]
line [0.25, 0.49, 0.68, 0.80, 1.11, 1.13, 1.31, 1.46]
line [0.25, 0.47, 0.65, 0.77, 1.04, 1.13, 1.33, 1.50]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.78, 2.06, 3.09, 6.10, 11.43, 23.37, 51.70, 104.07]
line [0.90, 2.08, 3.80, 6.43, 11.13, 23.01, 52.02, 103.86]
line [0.79, 2.15, 3.40, 6.49, 11.07, 23.41, 53.20, 104.65]
|
MemoryLayoutOf cached.memoryLayoutOf cache
There was a problem hiding this comment.
✅ No new issues found — the stride refactor is behavior-preserving and the layout cache is sound.
Reviewed changes
strideOfhelper — new internal export inschemaMemoryLayout.ts:285(roundUp(getMemoryLayout(schema.elementType).size, alignmentOf(schema))) consolidating ad-hoc stride math at 8 call sites inwriteSoA.ts,webgpuLimitations.ts,vertexLayout.ts,compiledIO.ts,dataIO.ts,offsetUtils.ts, andpartialIO.ts.- Intermediate layout caching — recursive child calls in
computeMemoryLayoutnow go through the newgetMemoryLayout, memoizing into the existingcachedLayoutsWeakMap;getLayoutInfodelegates to it. - Regression test —
tests/internal/schemaMemoryLayoutCache.test.tspins that a nested schema's custom size is read exactly once.
Behavior is unchanged: alignmentOf(WgslArray) delegates to alignmentOf(elementType) and alignmentOf(Disarray) to customAlignmentOf(elementType) (array/disarray are absent from knownAlignmentMap), so every replaced expression yields the same numeric stride. Verified the full packages/typegpu/tests suite passes (2970 tests across 199 files) and the only tsc --noEmit errors — the dataIO.ts array/disarray writer signature mismatches at lines 264/468 — are pre-existing on the base branch, not introduced here. No public API surface change and no new import cycle.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
c6051ef to
49e7996
Compare
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased (max -0.18%) | ➖ Unchanged | 🔴 Increased (max 0.53%) | ❔ Unknown |
|---|---|---|---|
| 32 | 320 | 3 | 0 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
| Test | tsdown |
|---|---|
| d_alignmentOf.ts | 29.10 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
49e7996 to
61a6a28
Compare

Changes:
strideOfhelpercomputeMemoryLayoutOf