[FFmpeg-devel] [PATCH] HTTP: optimize forward seek performance

Joel Cunningham joel.cunningham at me.com
Thu Jan 12 18:59:56 EET 2017


Nicolas,

I’ve found existing “read-ahead logic” in avio_seek to do what I’ve implemented in http_stream_forward().  This is controlled by SHORT_SEEK_THRESHOLD, currently set to 4KB.  I proto-typed increasing this to the 256KB (matches the initial TCP window in my test setup) and saw the same number of reduction in HTTP GETs and the number of seeks!  Thanks for the heads up, this should reduce my patch size!

I could plumb this setting (s->short_seek_threshold) to a URL function that would get the desired value from HTTP/TCP.  Looking at how ffio_init_context() is implemented, it doesn’t appear to have access to the URLContext pointer.  Any guidance on how I can plumb the protocol layer with aviobuf without a public API change?

Thanks,

Joel

> On Jan 12, 2017, at 9:29 AM, Joel Cunningham <joel.cunningham at me.com> wrote:
> 
> 
>> On Jan 12, 2017, at 6:53 AM, Nicolas George <george at nsup.org> wrote:
>> 
>> Le duodi 22 nivôse, an CCXXV, Joel Cunningham a écrit :
>>> This commit optimizes HTTP forward seeks by advancing the stream on
>>> the current connection when the seek amount is within the current
>>> TCP window rather than closing the connection and opening a new one.
>>> This improves performance because with TCP flow control, a window's
>>> worth of data is always either in the local socket buffer already or
>>> in-flight from the sender.
>> 
>> Thanks for the patch. You may have not noticed, but there is already a
>> similar logic in the higher-level API, aviobuf. See the code for
>> avio_seek(). I suspect it would be a better place to implement the logic
>> of avoiding seeks on slow-ish protocols.
> 
> Thanks for the feedback, I’ll take a look into how the forwarding logic could be implemented in avio_seek().  I do want to be careful that this logic doesn’t execute for non-HTTP or non-stream based protocols which don’t have flow control/automatic buffering of data.
> 
> Joel
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



More information about the ffmpeg-devel mailing list