#146 closed defect (fixed)
Strengthen calls to avcodec_decode_video2
Reported by: | ahuillet | Owned by: | Antoine Martin |
---|---|---|---|
Priority: | major | Milestone: | 0.4 |
Component: | client | Version: | 0.1.0 |
Keywords: | Cc: |
Description
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.
Attachments (5)
Change History (13)
Changed 9 years ago by
Attachment: | xpra-decompress-padded-nogil.patch added |
---|
comment:1 Changed 9 years ago by
Owner: | changed from Antoine Martin to ahuillet |
---|---|
Status: | new → assigned |
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.
comment:2 Changed 9 years ago by
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
?
comment:3 Changed 9 years ago by
Owner: | changed from ahuillet to Antoine Martin |
---|---|
Status: | assigned → accepted |
from ahuillet on irc: "align to 64 bits, align to sizeof(void *) - that's the best"
Changed 9 years ago by
Attachment: | gil-vs-nogil-CPU.svg added |
---|
comparing client CPU usage before and after patch
comment:4 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
applied in r973
As can be seen here:
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):
Changed 9 years ago by
Attachment: | gil-vs-nogil-client-latency.svg added |
---|
comparing client UI thread latency before and after patch
comment:5 Changed 9 years ago by
Changed 9 years ago by
Attachment: | x264-gil-vs-nogil.csv added |
---|
sample from the test results in raw csv format
comment:6 Changed 9 years ago by
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
comment:8 Changed 6 weeks ago by
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/146
copy the input buffer and pad it with zeroes, allows us to drop the gil