On Mon, 8 Jul 2019 09:05:04 -0700
Steve Kargl <s...@troutmask.apl.washington.edu> wrote:

> On Mon, Jul 08, 2019 at 04:02:17PM +0300, Janne Blomqvist wrote:
> > 
> > Good point. If you happen to have a USB stick handy, can you try the
> > simple C benchmark program at
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91030#c38 ?
> > 
> > (the kernel will coalesce IO's by itself, so the granularity of IO
> > syscalls is not necessarily the same as the actual IO to devices.
> > Network filesystems like NFS/Lustre/GPFS may have less latitude here
> > due to coherency requirements etc.)

GFORTRAN_BUFFER_SIZE_FORMATTED sounds a bit odd, maybe
GFORTRAN_(UN)FORMATTED_BUFFER_SIZE would read more natural.

And let me note 2 flaws in the benchmark:

>       left = N;
>       w = p;
>       t1 = walltime();
>       while (left > 0)
>         {
>           if (left >= blocksize)
>             to_write = blocksize;
>           else
>             to_write = left;
> 
>           write (fd, w, blocksize);

1) this should write to_write, not blocksize i assume.
2) you don't catch short writes

>           w += to_write;
>           left -= to_write;
>         }

So, short of using iozone, it should probably be more like (modulo
typos):
      left = N;
      w = p;
      t1 = walltime();
      while (left > 0)
        {
          if (left >= blocksize)
            to_write = blocksize;
          else
            to_write = left;
          while (to_write > 0) {
            errno = 0;
            ssize_t wrote = write (fd, w, to_write);
            if (wrote < 0 && errno != EINTR) /* retry EINTR or bail */
              break;
            w += wrote;
            left -= wrote;
            to_write -= wrote;
          }
        }
thanks,

Reply via email to