\begin{exe} {Comparing I/O Schedulers}

   We provide a script which is to be used to compare I/O
   schedulers which can be extracted from your downloaded
   \verb?SOLUTIONS? file as
   \lablink{lab\_iosched.sh}.

   \shfile[lab\_iosched.sh]{labs/lab_iosched.sh}

   If you are taking the online self-paced version of this course,
   the script is available for download from your \textbf{Lab}
   screen.

   Because changing the I/O scheduler is a privileged operation,
   you will have to run it as:
   \begin{cmd}
$ sudo ./lab_iosched.sh [# reads/writes (NMAX)] [file size in MB (NMEGS)]
   \end{cmd}

   \begin{howitworks}
      The script:
      \begin{itemize}
         \item
         Cycles through the available I/O schedulers on a hard
         disk while doing a configurable number of parallel
         reads and writes of files of a configurable size.
         (Note that exactly which schedulers are available will
         depend on the kernel has been configured and compiled
         and may vary quite a bit from machine to machine.)

         \item
         Tests reads and writes as separate steps.

         \item
         Makes sure, when testing reads, it is actually reading
         from disk and not from cached pages of memory; the
         cache is flushed out by doing (as root):

         \begin{cmd}
echo 3 > /proc/sys/vm/drop_caches
       \end{cmd}
         before doing the reads. The script does a \textbf{cat}
         into \filelink{/dev/null} to avoid writing to disk.

         \item
         Makes sure all reads are complete before obtaining
         timing information; this is done by issuing a
         \textbf{wait} command under the shell.

         \item

         Tests writes by simply copying a file (which will be in
         cached memory after the first read) multiple times
         simultaneously. To make sure it has waited for all writes
         to complete before getting timing information, it
         issues a \textbf{sync} call.
      \end{itemize}

   \end{howitworks}

   The provided script takes two arguments.  The first is
   the number of simultaneous reads and writes to perform.
   The second is the size (in MB) of each file.

   This script must be run as root as it echoes values into
   the \filelink{/proc} and \filelink{/sys} directory trees.

   Compare the results you obtain using different I/O
   schedulers.

   \begin{lfbox}[Extra Credit]
      For additional exploring you might try changing some
      of the tunable parameters and see how results vary.
   \end{lfbox}
\end{exe}

