Speed of memcpy() on NXP i.MX8 Plus

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Speed of memcpy() on NXP i.MX8 Plus

926 次查看
mdeluca_ph
Contributor III
We are capturing video buffers in our user-mode application using a video for linux driver.  The driver holds N buffers and we offload the data to user space using memcpy().  I have profiled this operation and it take about ~22ms to copy 1080x1440x2 = 3,110,400 bytes, about 142MBytes/sec.  Our previous experience leads us to expect about 5ms for the same transfer.  This ~22ms execution of memcpy() of 3,110,400 bytes is causing a problem in our frame capture, the kernel buffers get overwritten because we cannot copy them fast enough.  Do you have any benchmarks as a comparison, or techniques for faster transfers?  I've already tried 4K aligned user space buffers.
标签 (1)
0 项奖励
回复
1 回复

917 次查看
malik_cisse
Senior Contributor I

Hi,

memcpy() from mmap buffer has very poor performance. You can do benchmarks but you will finally come to the conclusion that this just does not work in real time applications. I have tried same implementations also.
What you want is "zero copy" e.g exporting file descriptor of DMA V4L2 Buffer as described here (especially slide 15):
https://elinux.org/images/5/53/Zero-copy_video_streaming.pdf

Also it depends what you want to do with the buffer. Gstreamer application could be a good choice. In Gstreamer you can use "appsink" to fetch buffers. In general, zero copy is quite a complex task. gstreamer hides all that complexity from you.