Performance regression when using vcsm-cma instead of vcsm, with zero copy MMAL
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c, linux
- Domain
- embedded-iot, operating-systems, performance
Research direction
Reproduce the regression by applying the linked patch to RaspiVid.c and running the resulting raspivid binary with '-o foo.h264'. Compare the first-20-row timings and CPU usage with vcsm and vcsm-cma, using the stated firmware and kernel versions; done means explaining or correcting the slowdown while preserving zero-copy MMAL behavior.
Written by the indexing model from the issue text.
Description
Describe the bug
When using MMAL_PARAMETER_ZERO_COPY in combination with vcsm-cma, using the cpu to read from frames captured by a camera in MMAL_ENCODING_I420 format slows down significantly -- taking over 30x longer in a particular benchmark, compared to using the previous vcsm implementation.
In addition to the greater time taken, the CPU usage reported by top is higher (~20% instead of ~2%). Removing the calls to set MMAL_PARAMETER_ZERO_COPY regains the faster timing, but CPU usage remains high.
Steps to reproduce the behaviour
The problem can be seen by applying the patch at https://gist.github.com/malc0/0a9ee21fd92ecc1e37a18fa6507b069e to RaspiVid.c from the current (54fd97ae4066a10b6b02089bc769ceed328737e0) userland repository, and comparing the output of running the resulting raspivid binary with '-o foo.h264'. Using the final 5.4 kernel from the firmware repository (8cd76653b88939baf25c3f9d9ce90657bcc19b76) the time to read the first 20 rows of a 1920 pixels-wide image is ~200 microseconds. Renaming /dev/vcsm to something else results in the vcsm-cma mechanism being used, and the same delay is typically greater than 6000 microseconds. Using the most recent 5.15.x firmware commit (494eb71e5adfca31ec65dd535fce73de3c7c2efa) shows similar times for vcsm-cma, but comparison to vcsm isn't possible.
Device (s)
Raspberry Pi 3 Mod. B+
System
OS: Raspbian GNU/Linux 11, dist-upgraded from jessie originally installed using https://github.com/debian-pi/raspbian-ua-netinst
vcgencmd version: Dec 12 2022 12:00:07
Copyright (c) 2012 Broadcom
version ed6f6b8fcdc6476410b9cf75d141633461d34bdd (clean) (release) (start_x)
uname -a: Linux localhost 5.15.83-v7+ #1607 SMP Thu Dec 15 12:55:05 GMT 2022 armv7l GNU/Linux
Logs
No response
Additional context
cmdline.txt:
dwc_otg.lpm_enable=0 dwc_otg.fiq_enable=0 dwc_otg.fiq_fsm_enable=0 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
config.txt:
start_x=1
gpu_mem=256
dtoverlay=cma,cma-96
dtoverlay=disable-bt
- Dominant language
- C
- Stars
- 13.2k
- Forks
- 5.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 21
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/linux
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7415 · 2 comments · 1 reaction ·
-
rp1-cfe doesn't forward V4L2_EVENT_SOURCE_CHANGE event from csi-2 sensor driver to userspace app Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
raspberrypi/linux#7399 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
raspberrypi/linux#7357 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/linux#7054 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
raspberrypi/linux#7634 · 8 comments · 1 reaction ·
All issues in raspberrypi/linux
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
BasedHardware/omi#15320 ·
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·