diff mbox

[FFmpeg-devel] avformat/file: increase max packet size to 256k for written files

Message ID 20170605171657.11113-1-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint June 5, 2017, 5:16 p.m. UTC
Another huge performance improvement when using SMB/CIFS as output.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/file.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Tobias Rapp June 16, 2017, 3:13 p.m. UTC | #1
On 05.06.2017 19:16, Marton Balint wrote:
> Another huge performance improvement when using SMB/CIFS as output.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/file.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/file.c b/libavformat/file.c
> index 264542a36a..ae7231a484 100644
> --- a/libavformat/file.c
> +++ b/libavformat/file.c
> @@ -227,6 +227,11 @@ static int file_open(URLContext *h, const char *filename, int flags)
>
>      h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
>
> +    /* Buffer writes more than the default 32k to improve throughput especially
> +     * with networked file systems */
> +    if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
> +        h->max_packet_size = 262144;
> +
>      return 0;
>  }
>

My tests show ~50% improved throughput rates. LGTM, but I'm not the 
maintainer of this file.

Thanks,
Tobias
Michael Niedermayer June 17, 2017, 7:35 p.m. UTC | #2
On Mon, Jun 05, 2017 at 07:16:57PM +0200, Marton Balint wrote:
> Another huge performance improvement when using SMB/CIFS as output.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/file.c | 5 +++++
>  1 file changed, 5 insertions(+)

is this intended to cause any change in output ?

the following changes:
./ffmpeg-old -i ~/videos/matrixbench_mpeg2.mpg -vb 100k -f hds -t 3  hdstest-old

hdstest-new:
total 404
drwxr-x---   2 michael michael   4096 Jun 17 21:35 ./
drwxr-xr-x 168 michael michael 393216 Jun 17 21:35 ../
-rw-r-----   1 michael michael    760 Jun 17 21:35 index.f4m
-rw-r-----   1 michael michael    106 Jun 17 21:35 stream0.abst
-rw-r-----   1 michael michael      4 Jun 17 21:35 stream0Seg1-Frag1

hdstest-old:
total 492
drwxr-x---   2 michael michael   4096 Jun 17 21:35 ./
drwxr-xr-x 168 michael michael 393216 Jun 17 21:35 ../
-rw-r-----   1 michael michael    760 Jun 17 21:35 index.f4m
-rw-r-----   1 michael michael    106 Jun 17 21:35 stream0.abst
-rw-r-----   1 michael michael  93406 Jun 17 21:35 stream0Seg1-Frag1


[...]
Marton Balint June 18, 2017, 2:55 p.m. UTC | #3
On Sat, 17 Jun 2017, Michael Niedermayer wrote:

> On Mon, Jun 05, 2017 at 07:16:57PM +0200, Marton Balint wrote:
>> Another huge performance improvement when using SMB/CIFS as output.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavformat/file.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> is this intended to cause any change in output ?
>
> the following changes:
> ./ffmpeg-old -i ~/videos/matrixbench_mpeg2.mpg -vb 100k -f hds -t 3  hdstest-old
>
> hdstest-new:
> total 404
> drwxr-x---   2 michael michael   4096 Jun 17 21:35 ./
> drwxr-xr-x 168 michael michael 393216 Jun 17 21:35 ../
> -rw-r-----   1 michael michael    760 Jun 17 21:35 index.f4m
> -rw-r-----   1 michael michael    106 Jun 17 21:35 stream0.abst
> -rw-r-----   1 michael michael      4 Jun 17 21:35 stream0Seg1-Frag1
>
> hdstest-old:
> total 492
> drwxr-x---   2 michael michael   4096 Jun 17 21:35 ./
> drwxr-xr-x 168 michael michael 393216 Jun 17 21:35 ../
> -rw-r-----   1 michael michael    760 Jun 17 21:35 index.f4m
> -rw-r-----   1 michael michael    106 Jun 17 21:35 stream0.abst
> -rw-r-----   1 michael michael  93406 Jun 17 21:35 stream0Seg1-Frag1
>

That seems to be aviobuf related. I will re-post the full patch series 
again soon, as I made some changes locally in aviobuf as well.

Thanks,
Marton
diff mbox

Patch

diff --git a/libavformat/file.c b/libavformat/file.c
index 264542a36a..ae7231a484 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -227,6 +227,11 @@  static int file_open(URLContext *h, const char *filename, int flags)
 
     h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
 
+    /* Buffer writes more than the default 32k to improve throughput especially
+     * with networked file systems */
+    if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
+        h->max_packet_size = 262144;
+
     return 0;
 }