Xpra: Ticket #146: Strengthen calls to avcodec_decode_video2

Hello,

 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
 * the actual read bytes because some optimized bitstream readers read 32 or 64
 * bits at once and could read over the end.

We don't currently do that, and this could theoretically yield segfaults.

While we're at it, the input buffer should be aligned on a 32bit boundary, and it should end with a 0.



Fri, 22 Jun 2012 08:56:24 GMT - Antoine Martin: attachment set

copy the input buffer and pad it with zeroes, allows us to drop the gil


Fri, 22 Jun 2012 08:59:31 GMT - Antoine Martin: owner, status changed

Please review the patch above (replacing 32 with 8... bits vs bytes, 64 vs 32!)

Looks fine to me, let's also try to get some numbers using the test script, I suspect this will improve parallelism which may be slightly detrimental to "client UI thread latency" (since this code runs in the UI thread)

Padding all pixel packets would be much more costly and impractical.


Fri, 22 Jun 2012 19:53:23 GMT - Antoine Martin:

We would need to use posix_memalign to ensure the memory is aligned:

 int posix_memalign (void **memptr, size_t alignment, size_t size)

What does it need to be aligned to? 32bit? alignment=4?


Fri, 22 Jun 2012 20:34:33 GMT - Antoine Martin: owner, status changed

from ahuillet on irc: "align to 64 bits, align to sizeof(void *) - that's the best"


Mon, 25 Jun 2012 10:00:22 GMT - Antoine Martin: attachment set

comparing FPS before and after patch


Mon, 25 Jun 2012 10:04:54 GMT - Antoine Martin: attachment set

comparing client CPU usage before and after patch


Mon, 25 Jun 2012 10:06:39 GMT - Antoine Martin: status changed; resolution set

applied in r973

As can be seen here: https://www.xpra.org/trac/raw-attachment/ticket/146/gil-vs-nogil-FPS.svg We can push roughly the same number of frames per second, with the exception of the 'gtkperf' test (which is pathological) and 'eruption' (not sure why).

More importantly, we do not adversely affect CPU usage, which is mostly unchanged (user CPU + system CPU shown): https://www.xpra.org/trac/raw-attachment/ticket/146/gil-vs-nogil-CPU.svg


Mon, 25 Jun 2012 10:12:51 GMT - Antoine Martin: attachment set

comparing client UI thread latency before and after patch


Mon, 25 Jun 2012 10:18:56 GMT - Antoine Martin:

Also, since we don't hold the gil as much as before, the client UI thread latency is improved in most cases (except for gtkperf - which can be ignored as it creates many small and short-lived windows, and glxgears - unsure why): https://www.xpra.org/trac/raw-attachment/ticket/146/gil-vs-nogil-client-latency.svg


Mon, 25 Jun 2012 10:20:09 GMT - Antoine Martin: attachment set

sample from the test results in raw csv format


Wed, 04 Jul 2012 08:17:45 GMT - Antoine Martin:

Need to fix win32:

codec.obj : error LNK2019: \
    unresolved external symbol _posix_memalign referenced in function \
    ___pyx_pf_4xpra_4x264_5codec_7Decoder_6decompress_image_to_rgb

Wed, 04 Jul 2012 08:25:02 GMT - Antoine Martin:

Here is the win32 equivallent called _aligned_malloc


Sat, 23 Jan 2021 04:46:47 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/146