Skip to content

zink: clear resource lookup hints while retiring batch references - #1417

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
fix/neo-zink-batch-89ddabbf
Nov 30, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
fix/neo-zink-batch-89ddabbf

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 30, 2026 •

Copy link
Copy Markdown

What

Zink cleared a 64 KiB buffer-index table on every batch reset, even for a dispatch that references one storage buffer. Clear the occupied hash buckets as their buffer objects are released. Fresh batch states still initialize every bucket, and collisions retain the existing pointer check and fallback search.

Tested

MacBook Neo (J700, A18 Pro, G17P B1), stock Fedora 44 kernel 7.3.0-41.fc44.aurora.aarch64. Zink on Borealis, Mesa base 89ddabbf72c251ff2eaabecb8ebf0ec4755a0269, head e0a85e963c3c3a8dd8b632cb550008d380f44f1c. Both arms loaded checksum-verified Gallium, EGL and Borealis libraries. The depth-16 FIFO went from 18.709 to 17.501 µs per completed dispatch, a 6.55% paired latency reduction.

The checked compute.light fixture uses the GPUBench shader at a5409150182f9dd0f951ace2d009a832c3d449a1. Each process ran light-gl DEPTH rate with a 300 ms warmup and five 250 ms windows, then verified the output and guard words in every slot. The executor used EGL_PLATFORM=surfaceless, MESA_LOADER_DRIVER_OVERRIDE=zink, MESA_SHADER_CACHE_DISABLE=true and private EGL and Vulkan manifests. Both CPU policies were fixed at 2.472 and 1.464 GHz. Each qualified block held GPU P10 at 1.470 GHz through the timed windows. The application inherited its normal CPU mask.

Each depth had four qualified A/B blocks alternating ABBA and BAAB and four matched base/base blocks. Latency change is the median of the blockwise ratios. The drift bound is the largest absolute matched base/base change.

Depth Base µs Head µs Paired latency change A/A bound
1 109.316 109.422 +0.15% 1.48%
2 54.111 55.031 +1.25% 4.34%
4 22.246 21.747 -2.17% 1.77%
8 18.472 17.645 -4.84% 2.78%
16 18.709 17.501 -6.55% 2.66%
32 18.937 17.761 -6.21% 2.64%
64 18.456 17.794 -5.33% 5.05%

The depth-1 and depth-2 increases remained inside their respective A/A bounds. Every retained timing row passed readback. Fixture source, exact commands, raw windows and scorer

The supplemental GLES31 CTS run on Zink passed all 2,360 cases on both arms with identical case statuses (195 compute, 104 synchronization and 2,061 SSBO). Every shard loaded its staged Gallium, EGL and Borealis libraries. The stock Neo returned with four SLC planes, zero failed units and zero GPU faults, kernel WARNs or AVCs.

Risk

The lookup table is a hint shared by the batch object lists. Batch reset visits every referenced object and clears its bucket before dropping the reference. Repeated and colliding keys can clear the same bucket more than once. Dense batches trade a contiguous clear for a store per retired reference.

Not yet

A second GPU-generation row is pending before merge.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 30, 2026 15:57

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at e0a85e96

Blockers:

  • Second GPU-generation row pending: per Not yet, only MacBook Neo (J700, G17P B1) has been run at e0a85e96; a second GPU-generation row is pending before merge.

Checked:

  • Audited src/gallium/drivers/zink/zink_batch.c (+6/-2) against all buffer_indices_hashlist references in zink_batch.c.
  • Verified zink_create_batch_state() still initializes all BUFFER_HASHLIST_SIZE entries to -1, and reset_batch_state_internal() calls reset_obj() on every object across all six batch lists (real_objs, slab_objs, sparse_objs, unsync_objs, swapchain_obj_unsync, swapchain_obj), clearing bs->buffer_indices_hashlist[bo->unique_id & (BUFFER_HASHLIST_SIZE - 1)] = -1 before releasing each BO reference.
  • Verified hash collisions remain safe via the existing buffer_index < list->num_buffers && list->objs[buffer_index] == obj check and linear fallback in batch_find_resource().
  • Exact-head MacBook Neo (J700, G17P B1, Zink on Borealis) row at e0a85e96 confirmed -6.55% depth-16 FIFO latency (18.709 -> 17.501 us), 2,360/2,360 GLES31 CTS Pass, 0 GPU faults; MERGEABLE against aurora-wip. Code is clean and ready to approve once the second GPU-generation row lands.
Evidence
  • Head SHA: e0a85e963c3c3a8dd8b632cb550008d380f44f1c (base=aurora-wip, MERGEABLE).

@DjDeveloperr

Copy link
Copy Markdown
Author

Review at e0a85e96: the code looks correct. No changes needed.

What I checked:

  • The table only speeds up lookups. batch_find_resource() still checks list->objs[idx] == obj and falls back to a linear search. A missed or extra clear can cost a search, but it can't return a wrong index.
  • Every bucket that gets set belongs to an object that is in a batch list at that moment. Buckets are set in batch_reference_resource_move_internal() and in the collision path of batch_find_resource(). obj->bo and bo->unique_id don't change after creation. Reset runs reset_obj() on all four lists and both swapchain arrays, so every set bucket is cleared before the batch state is reused. New batch states still start from the full memset.
  • The bucket is cleared before zink_resource_object_reference() drops the reference, so bo is still valid when it's read.
  • This is common Zink code with no dependence on the Vulkan driver, so the same reasoning holds for RADV, ANV, NVK, Turnip and lavapipe. The clear runs in the same function and on the same thread as the old memset.
  • The change builds without warnings on x86_64 (asahi + zink, debugoptimized).

What's left before merge: a hardware row at this head on a second GPU generation (G15 or G16).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 26c786fd

Blockers:

  • Second GPU-generation hardware row remains pending before merge (Not yet: only MacBook Neo J700 G17P B1 has been run so far).

Checked:

  • Forward merge 26c786fd onto aurora-wip: zero conflicts and identical +6/-2 diff in src/gallium/drivers/zink/zink_batch.c (reset_obj() clears bs->buffer_indices_hashlist[bo->unique_id & (BUFFER_HASHLIST_SIZE - 1)] = -1 while retiring each referenced BO instead of a full 64 KiB memset in reset_batch_state_internal()).
  • Fresh batch states still initialize all buckets to -1, and batch_find_resource() retains its pointer check and fallback search.
Evidence
  • Code remains clean with zero defects found; ready to approve once the second GPU-generation hardware row is posted.

@DjDeveloperr

DjDeveloperr commented Nov 30, 2026 •

Copy link
Copy Markdown
Author

J773g (M4 mini, T8132 G16G) peer row: parity. Zink d16 at e0a85e963c3c (this PR's commits) vs base 89ddabbf72c2: −0.58 % paired, inside the 1.32 % A/A drift. Every slot's output, guard words and CRC are verified in every leg.

The PR head is now 26c786fd4ef8. It differs from e0a85e96 only by a merge of aurora-wip (#1419, #1358), which doesn't touch this PR's change.

Row base this PR paired Δ largest A/A Δ qualified blocks
Zink compute row d16 (µs) 35.246 35.029 −0.584 % 1.315 % 4 A/B (ABBA/BAAB), 4 A/A
  • Hardware: J773g (M4 mini, T8132 G16G), saved stock Arch kernel 7.3.0-ARCH-m4mainefed1ae3 with SLC on both planes.
  • Clocks: effective GPU state S10 on every qualified block. CPU clusters fixed at 4,104,000 / 2,892,000 kHz for the run (the highest advertised frequencies), then restored to stock schedutil 912,000–4,464,000 / 900,000–2,892,000 kHz.
  • Stock checks: passed before and after on the same boot: no pending boot entry, 0 failed units, 0 GPU faults, recoveries or hangs. The rows are silent.
  • Kit: Neo lead's second-generation kit (kit.tar.zst 5101a11b). Each arm loads its own Gallium/EGL/GBM/Borealis overlay with Borealis vendor 0x10005, verified per leg. The kit's identity probe needed eglGetPlatformDisplayEXT on Arch libepoxy; that's the same entry point the benchmark uses.

GLES31 conformance: 2,360 cases per arm (195 compute, 104 synchronization, 2,061 SSBO). Base and this PR both gave 2,360 Pass, 0 Fail, with identical case-by-case status. 0 GPU faults, driver warnings, recoveries or hang kills.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 26c786fd

Blockers: none.

Checked:

  • src/gallium/drivers/zink/zink_batch.c (+6/-2): reset_obj() clears bs->buffer_indices_hashlist[bo->unique_id & (BUFFER_HASHLIST_SIZE - 1)] = -1 while retiring each referenced BO instead of a full 64 KiB memset in reset_batch_state_internal(). Fresh batch states still initialize all buckets to -1, and batch_find_resource() retains its pointer check and linear fallback search.
  • Forward merge 26c786fd onto aurora-wip: zero conflicts, zero diff vs e0a85e96 in Zink.
  • Dual GPU-generation hardware verification complete:
    • MacBook Neo (J700, A18 Pro, G17P B1): -6.55% paired latency reduction at depth-16 (18.709 -> 17.501 µs), all 2,360 GLES31 CTS cases passed (195 compute, 104 synchronization, 2,061 SSBO), 0 faults.
    • Mac mini M4 (J773g, T8132, G16G): parity at depth-16 (35.246 -> 35.029 µs, -0.584% paired inside 1.315% A/A drift across 4 A/B + 4 A/A qualified blocks), every slot's output/guard words/CRC verified, 0 GPU faults/recoveries/hangs.
Evidence
  • Code independently verified clean; both GPU-generation hardware rows pass with zero faults or regressions. Ready to merge into aurora-wip.

@RyanTheTide

Copy link
Copy Markdown

@DjDeveloperr, code-owner heads-up: App approval at 26c786fd4ef8 from a different lane. This PR goes into the merge train's next combined A/B (aurora-wip 6e153e59 + #1417 #1418 #1425) on M1 Pro G13S + M4 G16G. If that row is clean, I plan to land it via --admin under the 6-point rule no earlier than one hour from now, unless you post a hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants