@@ -649,18 +649,24 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
649649#endif
650650 if (f == NULL ) {
651651 DISPLAYLEVEL (1 , "zstd: %s: %s\n" , dstFileName , strerror (errno ));
652+ } else {
653+ /* An increased buffer size can provide a significant performance
654+ * boost on some platforms. Note that providing a NULL buf with a
655+ * size that's not 0 is not defined in ANSI C, but is defined in an
656+ * extension. There are three possibilities here:
657+ * 1. Libc supports the extended version and everything is good.
658+ * 2. Libc ignores the size when buf is NULL, in which case
659+ * everything will continue as if we didn't call `setvbuf()`.
660+ * 3. We fail the call and execution continues but a warning
661+ * message might be shown.
662+ * In all cases due execution continues. For now, I believe that
663+ * this is a more cost-effective solution than managing the buffers
664+ * allocations ourselves (will require an API change).
665+ */
666+ if (setvbuf (f , NULL , _IOFBF , 1 MB )) {
667+ DISPLAYLEVEL (2 , "Warning: setvbuf failed for %s\n" , dstFileName );
668+ }
652669 }
653- /* An increased buffer size can provide a significant performance boost on some platforms.
654- * Note that providing a NULL buf with a size that's not 0 is not defined in ANSI C, but is defined
655- * in an extension. There are three possibilities here -
656- * 1. Libc supports the extended version and everything is good.
657- * 2. Libc ignores the size when buf is NULL, in which case everything will continue as if we didn't
658- * call `setvbuf`.
659- * 3. We fail the call and execution continues but a warning message might be shown.
660- * In all cases due execution continues. For now, I believe that this is a more cost-effective
661- * solution than managing the buffers allocations ourselves (will require an API change). */
662- if (setvbuf (f , NULL , _IOFBF , 1 MB ))
663- DISPLAYLEVEL (2 , "Warning: setvbuf failed for %s\n" , dstFileName );
664670 return f ;
665671 }
666672}
0 commit comments