impr: Small improvements for future concurrent-scan work - #2300
Closed
reczkok wants to merge 6 commits into
Closed
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (355 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the prefix-scan implementation to make per-thread element processing configurable (for upcoming concurrent-scan work), and enhances the docs test example with better failure logging plus a simple benchmark.
Changes:
- Introduces
ELEMENTS_PER_THREAD(and a shared range) to replace hardcoded “8 elements per thread” assumptions. - Updates scan/applySums compute kernels to use
tgpu.unroll(...)over the shared range for per-element work. - Improves the docs “prefix-scan” test example with mismatch logging, named test runner output, and an automatic benchmark run.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu-sort/src/scan/schemas.ts | Adds shared constants for elements-per-thread and its iteration range. |
| packages/typegpu-sort/src/scan/prefixScan.ts | Uses the new constant when computing workgroup counts. |
| packages/typegpu-sort/src/scan/compute/scan.ts | Switches per-thread element loops to tgpu.unroll and uses the new constants. |
| packages/typegpu-sort/src/scan/compute/applySums.ts | Updates uniform add pass to use the new constants + tgpu.unroll. |
| apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts | Adds detailed mismatch logging, a benchmark harness, and named test execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aleksanderkatan
approved these changes
May 13, 2026
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.95, 1.88, 3.97, 6.05, 7.38, 11.72, 20.67, 24.53]
line [0.98, 1.91, 4.21, 6.87, 7.71, 11.77, 21.48, 25.59]
line [1.00, 1.96, 4.29, 6.64, 8.45, 11.14, 21.91, 27.22]
---
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.33, 0.58, 0.74, 0.85, 1.18, 1.18, 1.45, 1.63]
line [0.30, 0.53, 0.72, 0.87, 1.23, 1.22, 1.47, 1.63]
line [0.32, 0.53, 0.70, 0.89, 1.11, 1.27, 1.53, 1.70]
---
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.90, 2.19, 3.71, 6.27, 12.84, 25.83, 54.97, 112.07]
line [0.88, 2.14, 3.92, 6.44, 12.50, 26.46, 56.32, 114.24]
line [0.93, 2.08, 4.63, 6.45, 12.83, 26.81, 56.72, 116.31]
|
reczkok
force-pushed
the
impr/easier-concurrent-scan-testing
branch
from
May 26, 2026 15:08
0ae73d1 to
48efd83
Compare
Collaborator
|
Superseded by #2756 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
use unroll, extract elements per thread (for easier testing), add benchmark, failed test logging
I experimented with workgroup size offset to avoid bank conflicts but from my testing it seemed to improve occupancy but did not improve performance so I dropped it for now