Skip to content

perf(cuda): reuse pinned buffer completion events - #10713

Open
0ax1 wants to merge 1 commit into
developfrom
ad/cuda-pinned-event-reuse
Open

0ax1 wants to merge 1 commit into
developfrom
ad/cuda-pinned-event-reuse

Conversation

@0ax1

@0ax1 0ax1 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Pinned-buffer reclamation allocates an extra completion event for each transfer.

Solution

Reuse the buffer owner's event to track inflight transfers.

Assessment

Preserves the source-retention guarantees and event flags from #10712, which must merge first.

@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 4 benchmarks

4 warnings, 1 note

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ Unable to measure the execution of 1 benchmark

This benchmark measured no execution time, so its result is not comparable and counts as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ 20 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 40 benchmarks have no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

⚡ 15 improved benchmarks
❌ 4 regressed benchmarks
✅ 2389 untouched benchmarks
⏩ 12 skipped benchmarks1
🗄️ 43 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation bench_compare_sliced_dict_primitive[(2000, 10000)] 13.1 µs 68.9 µs -80.97%
❌ CPU Simulation density_sweep_dense_runs[0.001] 44.5 µs 61.9 µs -28%
❌ Walltime starts_with_avx512[64, VarBin] 53.6 µs 62.2 µs -13.83%
❌ CPU Simulation random_i8[0.01] 103.5 µs 116.6 µs -11.27%
⚡ CPU Simulation prepare[1000] 430.3 µs 10.5 µs ×41
⚡ CPU Simulation prepare[100] 74.8 µs 10.5 µs ×7.1
⚡ CPU Simulation decompress[u32, (1000, 256)] 52.2 µs 31.5 µs +65.73%
⚡ CPU Simulation prepare[1] 16.5 µs 10.5 µs +57.2%
⚡ CPU Simulation scan[1] 95.6 µs 76.2 µs +25.39%
⚡ CPU Simulation prepare_and_compile[100] 323 µs 260.7 µs +23.9%
⚡ CPU Simulation prepare_and_compile[1000] 2.7 ms 2.2 ms +21.38%
⚡ CPU Simulation test_repeated_scan_scalar_at[int_float] 450.6 µs 371.3 µs +21.36%
⚡ CPU Simulation test_scan_filter_to_arrow_array[int_float] 4.1 ms 3.6 ms +13.57%
⚡ CPU Simulation test_scan_filter[int] 3.4 ms 3 ms +12.87%
⚡ CPU Simulation test_scan_filter_to_arrow_array[int] 2.8 ms 2.5 ms +11.15%
⚡ CPU Simulation test_repeated_scan_filter[int] 2.7 ms 2.5 ms +11.03%
⚡ CPU Simulation decompress[u64, (1000, 256)] 51 µs 46.2 µs +10.52%
⚡ CPU Simulation prepare_and_compile[1] 52.7 µs 47.8 µs +10.34%
⚡ CPU Simulation test_repeated_scan_filter[int_float] 3.9 ms 3.5 ms +10.06%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ad/cuda-pinned-event-reuse (81e4221) with ad/cuda-pinned-transfer-safety (40f13e2)3

Open in CodSpeed

Footnotes

  1. 12 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. 43 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

  3. No successful run was found on ad/cuda-pinned-transfer-safety (cd9ea47) during the generation of this report, so 159322e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@0ax1 0ax1 added the changelog/performance A performance improvement label Oct 23, 2026 — with ChatGPT Codex Connector
@0ax1
0ax1 force-pushed the ad/cuda-pinned-event-reuse branch from a03d03f to b0d3e4a Compare October 23, 2026 13:13
@0ax1
0ax1 force-pushed the ad/cuda-pinned-transfer-safety branch from 1f87c45 to 40f13e2 Compare October 23, 2026 13:13
@0ax1
0ax1 requested a review from robert3005 October 23, 2026 14:50
@0ax1
0ax1 marked this pull request as ready for review October 23, 2026 14:51
@0ax1
0ax1 force-pushed the ad/cuda-pinned-transfer-safety branch from 40f13e2 to cd9ea47 Compare October 23, 2026 15:44
@0ax1
0ax1 force-pushed the ad/cuda-pinned-event-reuse branch from b0d3e4a to 81e4221 Compare October 23, 2026 15:45
0ax1 added a commit that referenced this pull request Oct 23, 2026
## Problem

A failed or resubmitted transfer can recycle pinned source memory before its previous DMA completes.

## Solution

Check contexts, wait on the previous source fence, and establish completion before recycling buffers.

## Assessment

If completion cannot be established, retain the allocation rather than risk freeing active DMA memory. Based on #10726; prerequisite for #10713.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
Base automatically changed from ad/cuda-pinned-transfer-safety to develop October 23, 2026 17:14
Use each pinned buffer owner event for inflight reclamation instead of allocating another completion event per transfer. Preserve the source-retention and failure-recovery guarantees of the parent change.

Original-commit: ff5e49b1f0
Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
@0ax1
0ax1 force-pushed the ad/cuda-pinned-event-reuse branch from 81e4221 to 8acd798 Compare October 23, 2026 17:16

This branch has not been deployed

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

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants