Low performacne on SharedMemoryIOStream::readFully

Bug #2070265 reported by Gary.Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Anbox Cloud
Fix Released
Medium
Gary.Wang

Bug Description

The SharedMemoryIOStream::readFully function call, which is now used by the anbox hardware-based video
decoder (android.hardware.media.omx@1.0-service) to transfer the decoded video frame from the host side to the guest side via shared memory. The issue here was that it reads data from the cache first, if the requested data is not sufficient, it tries to read the data from shared memory further, and does a memcpy later. However, in such a case, the previously read data was not only overwritten (introducing corrupted video frames sporadically), but also adds extra overhead on the cpu to do the memcpy because it copies the buffer read from the shared memory to the head again.

When playing 1080p h264 video, e.g. big-buck-bunny-1080p-60fps-30sec.mp4,
the average time spent on reading each complete decoded video frame
from the host side on amd64 is gh ~ 8257 us

When profiling the media_codec Android process with perf

 51.16% 971 sh.h264.decoder libOpenglSystemCommon.so [.] std::__1::vector<unsigned char, std::__1::allocator<uns>
  6.88% 125 sh.h264.decoder libc.so [.] memmove_generic
  2.92% 14 sh.h264.decoder [kernel.kallsyms] [k] _raw_spin_lock
  1.25% 1 OMXCallbackDisp [kernel.kallsyms] [k] binder_stat_br

Gary.Wang (gary-wzl77)
Changed in anbox-cloud:
milestone: none → 1.23.0
assignee: nobody → Gary.Wang (gary-wzl77)
status: New → Fix Released
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.