[vlc-devel] [PATCH 0/1] Improve SFTP network performance with buffer

Martin Disch martindisch at gmail.com
Fri Mar 2 20:42:22 CET 2018


On Thu, Mar 1, 2018 at 9:25 AM, Ilkka Ollakka <ileoo at videolan.org> wrote:
> If you want to test the patch is hacked quickly like this:
>
> diff --git a/modules/access/sftp.c b/modules/access/sftp.c
> index 1219f573a1..c6939e570e 100644
> --- a/modules/access/sftp.c
> +++ b/modules/access/sftp.c
> @@ -520,7 +520,14 @@ static ssize_t Read( stream_t *p_access, void *buf,
> size_t len )
>  {
>      access_sys_t *p_sys = p_access->p_sys;
>
> +    /* Set the socket in non-blocking mode */
> +    libssh2_session_set_blocking( p_sys->ssh_session, 0 );
> +
>      ssize_t val = libssh2_sftp_read(  p_sys->file, buf, len );
> +    if( val == LIBSSH2_ERROR_EAGAIN )
> +    {
> +        return -1;
> +    }
>      if( val < 0 )
>      {
>          msg_Err( p_access, "read failed" );

I tried it and a few interesting things happened.

First after applying your patch, playback did not work at all, instead
stopping with "sftp stream error: read failed". I checked which error
it was that libssh2 was returning that caused this and it turned out
to be -31, which is LIBSSH2_ERROR_SFTP_PROTOCOL. I have no idea why
this happens on my system when it works on yours, but it's not that
big of a problem.

I worked around it by adding the error to the check you're already
doing for the EAGAIN error, which did the job. I didn't do any
elaborate measurements, but just looking at the bandwidth usage I
didn't see an improvement. I was using a large prefetch buffer again,
hoping to see the prefetch module fill it up quickly using all
available bandwidth, but unlike when using a large read size, it
didn't manage. It barely used enough bandwidth to keep up with
playback and couldn't really prefetch anything.

--
Martin Disch
martindisch at gmail.com


More information about the vlc-devel mailing list