Skip to content

[OpenCL:Feature] Accelerate MmapAllocator::read by replacing per-call lseek+read with mmap-based memcpy#4323

Closed
Riverspring996 wants to merge 2 commits into
alibaba:masterfrom
Riverspring996:opencl_memcpy_read
Closed

[OpenCL:Feature] Accelerate MmapAllocator::read by replacing per-call lseek+read with mmap-based memcpy#4323
Riverspring996 wants to merge 2 commits into
alibaba:masterfrom
Riverspring996:opencl_memcpy_read

Conversation

@Riverspring996

Copy link
Copy Markdown
Contributor

Changes

The cached file is already mapped at onAlloc time, so each read can be a plain memcpy from the pre-established mapping rather than issuing lseek+read syscalls, eliminating both the kernel syscall and the kernel-to-user copy.

Validation

Measured total wall-clock time of OpenCLMmapAllocator::read during model loading via Android ATrace, with multiple warm-up launches to exclude cold page-fault. Results confirm a reduction about 30% in OpenCLMmapAllocator::read and 14% in total loading.

read_duration memcpy_duration
  • Device: vivo X100/V2309A
  • Soc: Dimensity 9300
  • Kernel: Linux 6.1.124

@Qxinyu

Qxinyu commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your code commit. We have already addressed this issue internally, and the latest code has now been pulled.

@Qxinyu Qxinyu closed this Apr 2, 2026
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.

3 participants