Skip to content

perf(cuda): copy cached file pages directly on the GPU - #10716

Merged
0ax1 merged 1 commit into
developfrom
ad/cuda-mapped-copy
Oct 23, 2026
Merged

0ax1 merged 1 commit into
developfrom
ad/cuda-mapped-copy

Conversation

@0ax1

@0ax1 0ax1 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Cached file pages still pass through pinned staging buffers before reaching the GPU.

Solution

On supported Linux devices, copy resident mapped-file ranges directly with a CUDA kernel; retain staged reads for other cases.

Assessment

Hardware-dependent fast path with mapping lifetime and cancellation guards. Keeps 4 MiB chunks, so it is independent of #10715. Based on #10726.

@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

3 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

⚠️ 16 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

ℹ️ 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

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 2405 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
❌ Walltime starts_with_avx512[8, VarBin] 40 µs 45.3 µs -11.8%
⚡ CPU Simulation decode_primitives[i64, (1000, 8)] 37.6 µs 24 µs +56.62%
⚡ Walltime words_gather_dispatch_neon[65536] 2 µs 1.8 µs +10.67%

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-mapped-copy (5d8b5f3) with develop (e083440)

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. ↩

@0ax1 0ax1 added the changelog/performance A performance improvement label Oct 23, 2026 — with ChatGPT Codex Connector
@0ax1
0ax1 changed the base branch from develop to ad/ctutils-security-update October 23, 2026 13:13
@0ax1
0ax1 force-pushed the ad/cuda-mapped-copy branch from d006295 to 715005f 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
Base automatically changed from ad/ctutils-security-update to develop October 23, 2026 15:34
@0ax1
0ax1 force-pushed the ad/cuda-mapped-copy branch from 715005f to cbbedfc Compare October 23, 2026 15:42
On devices that read pageable memory through host page tables, copy resident mapped-file ranges directly into device memory. Preserve staged reads for uncached ranges and direct I/O, source and destination alignment, cancellation safety, and mapping lifetime guards. Use the existing file-read chunk size so this feature is independent of chunk-size tuning.

Original-commit: b546d93814
Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
@0ax1
0ax1 force-pushed the ad/cuda-mapped-copy branch from cbbedfc to 5d8b5f3 Compare October 23, 2026 15:42
@0ax1
0ax1 merged commit 32390c0 into develop Oct 23, 2026
163 of 168 checks passed
@0ax1
0ax1 deleted the ad/cuda-mapped-copy branch October 23, 2026 17:11
0ax1 added a commit that referenced this pull request Oct 23, 2026
## Problem

Repeated scans rebuild file mappings and page tables; caching them also needs explicit support for cold-cache eviction.

## Solution

Cache mappings by file identity/version and add `release_file_mappings()` and `vx_cuda_release_file_mappings()`.

## Assessment

Callers can release cached mappings before eviction while active readers retain ownership. Depends on #10716.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 3, 2026
Since #10716, opening a file for CUDA reads on devices that read
pageable memory maps the file so the device can copy cached pages
directly. A failed `mmap` failed the whole open, although the mapping
only speeds up reads that staging serves as well. Files on filesystems
without shared mappings, such as some FUSE mounts, could therefore no
longer be read at all on those devices.

Fall back to staged reads when the file cannot be mapped.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 3, 2026
`CudaOpenOptions::open_path` opened the path three times: for the
footer and zone maps, for the pooled data reader, and, since #10716,
for the mapping the device copies cached pages from. A file atomically
replaced at that path between the opens, as writers commonly publish
files, could therefore pair one file's footer with another's segments,
or serve resident ranges from one file's mapping and other ranges from
the other file. Files with compatible layouts then decoded wrong data
without any error.

Open the file once and give that handle to the control reader, through
the new `FileReadAt::from_file`, to the buffered data reader, and to
the mapping. Direct I/O needs a descriptor of its own, so it checks
that reopening the path reached the same file.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 6, 2026
Since #10716, opening a file for CUDA reads on devices that read
pageable memory maps the file so the device can copy cached pages
directly. A failed `mmap` failed the whole open, although the mapping
only speeds up reads that staging serves as well. Files on filesystems
without shared mappings, such as some FUSE mounts, could therefore no
longer be read at all on those devices.

Fall back to staged reads when the file cannot be mapped.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 6, 2026
`CudaOpenOptions::open_path` opened the path three times: for the
footer and zone maps, for the pooled data reader, and, since #10716,
for the mapping the device copies cached pages from. A file atomically
replaced at that path between the opens, as writers commonly publish
files, could therefore pair one file's footer with another's segments,
or serve resident ranges from one file's mapping and other ranges from
the other file. Files with compatible layouts then decoded wrong data
without any error.

Open the file once and give that handle to the control reader, through
the new `FileReadAt::from_file`, to the buffered data reader, and to
the mapping. Direct I/O needs a descriptor of its own, so it checks
that reopening the path reached the same file.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 6, 2026
Since #10716, opening a file for CUDA reads on devices that read
pageable memory maps the file so the device can copy cached pages
directly. A failed `mmap` failed the whole open, although the mapping
only speeds up reads that staging serves as well. Files on filesystems
without shared mappings, such as some FUSE mounts, could therefore no
longer be read at all on those devices.

Fall back to staged reads when the file cannot be mapped.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
0ax1 added a commit that referenced this pull request Nov 6, 2026
`CudaOpenOptions::open_path` opened the path three times: for the
footer and zone maps, for the pooled data reader, and, since #10716,
for the mapping the device copies cached pages from. A file atomically
replaced at that path between the opens, as writers commonly publish
files, could therefore pair one file's footer with another's segments,
or serve resident ranges from one file's mapping and other ranges from
the other file. Files with compatible layouts then decoded wrong data
without any error.

Open the file once and give that handle to the control reader, through
the new `FileReadAt::from_file`, to the buffered data reader, and to
the mapping. Direct I/O needs a descriptor of its own, so it checks
that reopening the path reached the same file.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
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