Modifying Samba to skip file system reads for IOZONE READ and REREAD

Richard Sharpe rsharpe at richardsharpe.com
Sun Oct 30 04:17:17 GMT 2005


On Fri, 28 Oct 2005, Iozone wrote:

[Savage deletion]

> Richard,
>
>       Your post did not include anything about this being a lab
>   experiment, but did offer to provide the hack to disable Iozone
>   accuracy.
>       Perhaps I am a bit overly sensitive, but the post could easily be
>   interpreted, by anyone in the world, as a valid mechanism to
>   blind side Iozone and have their Samba produce outrageous
>   results. There are no comments in the post about the intent
>   of the code.
>
>   My reading of the post was that this code is available from
>   you for anyone that desired to have it.  Thus, my reaction
>   to this technique.
>       I've lived in the benchmarking world for many years,
>   seen every dirty trick, and watched the consumers get
>   bit by such optimizations.  When I see something like
>   this, it really gets under my skin.
>
>       I agree that Iozone should take more care to avoid such
>   activities, and a new version will be available within
>   24 hours to address this issue.
>
>   Your post:
>   --------------------
> Hi,
>
> In exploring some performance issues I had with highly variable read
> performance (difference of 25MB/s between highest and lowest numbers), I
> modified Samba to skip file system reads for IOZONE files ...

In my earlier post I agreed that I had not made it clear that this was an 
experimental hack. Since this posting ocurred something like six months 
ago now I can no longer remember what I was thinking at the time, but:

    Never attribute to malevolence what can be more easily explained
    as thoughtlessness, overwork, etc ...

> Attached are the diffs ... in case anyone else wants to do something
> similar.

The patch itself really would not have been very useful for a production 
environment because it only used the file name to base its decisions on, 
and thus would be prone to false positives.

Moreover, I think you should view this situation as an arms race. People 
will find ways to game the system, which will require the benchmark 
writers to improve their benchmarks ...

I note that you have released a new version that makes it harder to use 
tricks like that while at the same time allowing file system people to 
explore the different areas of performance, so that is good.

> Regards
> -----
> Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
> sharpe[at]ethereal.com, http://www.richardsharpe.com
> -------------- next part --------------
> ==== //depot/branch/pioneer-mg/src/samba/source/include/smb.h#1 - 
> /usr1/rsharpe/rsharpe-calpc02-pioneer-mg/src/samba/source/include/smb.h ====
> @@ -415,6 +415,8 @@
> 	BOOL directory_delete_on_close;
> 	char *fsp_name;
> 	FAKE_FILE_HANDLE *fake_file_handle;
> +	BOOL iozone_file;
> +	char *buffer;
> #ifdef PANFS_LOCKS
> 	SMB_BIG_UINT share_lock_handle; /* Keeps a share lock */
> #endif
> ==== //depot/branch/pioneer-mg/src/samba/source/smbd/close.c#3 - 
> /usr1/rsharpe/rsharpe-calpc02-pioneer-mg/src/samba/source/smbd/close.c ====
> @@ -324,6 +324,8 @@
> 	if (fsp->fsp_name)
> 		string_free(&fsp->fsp_name);
>
> +        if (fsp->iozone_file) SAFE_FREE(fsp->buffer);
> +
> 	file_free(fsp);
>
> 	if (err == -1 || err1 == -1) {
> ==== //depot/branch/pioneer-mg/src/samba/source/smbd/open.c#4 - 
> /usr1/rsharpe/rsharpe-calpc02-pioneer-mg/src/samba/source/smbd/open.c ====
> @@ -327,6 +327,37 @@
> 			return False;
> 		}
>
> +		/*
> +		 * Little hack for IOZONE ... if name is iozone.DUMMY.
> +		 * then set a flag and create a buffer for read
> +		 */
> +                {
> +                  const char * slashloc = strrchr(fname, '/');
> +                  if (!slashloc) slashloc = fname;
> +                  if (strncmp(fname, "iozone.DUMMY.", 13) == 0) {
> +                    DEBUG(0, ("IOZONE file detected: %s. Using IOZONE 
> trick.\n",fname));
> +                    fsp->iozone_file = True;
> +                    fsp->buffer = (char *)malloc(65536);
> +                    if (!fsp->buffer) {
> +                      DEBUG(0, ("Unable to allocate memory for IOZONE trick. 
> Falling back.\n"));
> +                      fsp->iozone_file = False;
> +                    }
> +                    else {
> +                      int i, j;
> +                      memset(fsp->buffer, '\0', 65536);
> +                      /* set the funny pattern in the buffer */
> +                      for (i = 0; i < 65536; i += 32) {
> +                        fsp->buffer[i] = 0xA5;
> +                      }
> +                      for (i = 0; i < 65536; i = i + 4096) {
> +                        for (j = 0; j < 8; j++) {
> +                          fsp->buffer[i + j] = 0xA5;
> +                        }
> +                      }
> +                    }
> +                  }
> +                }
> +
> 		/* Inherit the ACL if the file was created. */
> 		if ((local_flags & O_CREAT) && !VALID_STAT(*psbuf))
> 			inherit_access_acl(conn, fname, mode);
> ==== //depot/branch/pioneer-mg/src/samba/source/smbd/reply.c#3 - 
> /usr1/rsharpe/rsharpe-calpc02-pioneer-mg/src/samba/source/smbd/reply.c ====
> @@ -2175,6 +2175,11 @@
>
> #endif
>
> +        if (fsp->iozone_file) {
> +          memcpy(data, fsp->buffer, smb_maxcnt);
> +          nread = smb_maxcnt;
> +        }
> +        else
> 	nread = read_file(fsp,data,startpos,smb_maxcnt);
>
> 	if (nread < 0) {
> ---------------- 
>

-- 
Regards
-------
Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
sharpe[at]ethereal.com, http://www.richardsharpe.com


More information about the samba-technical mailing list