<?xml version="1.0" encoding="utf-8"?>
<chapter>
    <title>Disk Seeks Considered Harmful</title>

    <para>
        Disk seeks are one of the most expensive operations you can possibly perform. You might not know this from looking at how many of them we perform, but trust me, they are. Consequently, please refrain from the following suboptimal behavior:
    </para>
    <itemizedlist>
        <listitem>
            <para>
                Placing lots of small files all over the disk.
            </para>
        </listitem>
        <listitem>
            <para>
                Opening, stating, and reading lots of files all over the disk
            </para>
        </listitem>
        <listitem>
            <para>
                Doing the above on files that are laid out at different times, so as to ensure that they are fragmented and cause even more seeking.
            </para>
        </listitem>
        <listitem>
            <para>
                Doing the above on files that are in different directories, so as to ensure that they are in different cylinder groups and and cause even more seeking.
            </para>
        </listitem>
        <listitem>
            <para>
                Repeatedly doing the above when it only needs to be done once.
            </para>
        </listitem>
    </itemizedlist>
    <para>Mögliche Wege, wie Sie Ihren Code suchfreundlich optimieren können:</para>
    <itemizedlist>
        <listitem>
            <para>Fassen Sie Daten in einer einzigen Datei zusammen.</para>
        </listitem>
        <listitem>
            <para>Halten Sie Daten im gleichen Ordner vor.</para>
        </listitem>
        <listitem>
            <para>Speichern Sie Daten zwischen, so dass sie nicht fortwährend erneut eingelesen werden müssen.</para>
        </listitem>
        <listitem>
            <para>Geben Sie Daten frei, so dass sie nicht beim Laden von Anwendungen immer wieder erneut gelesen werden müssen.</para>
        </listitem>
        <listitem>
            <para>Erwägen Sie, alle Daten in einer einzigen Binärdatei zwischenzuspeichern, die sauber aufgebaut ist und mit mmap verarbeitbar ist.</para>
        </listitem>
    </itemizedlist>
    <para>
        The trouble with disk seeks are compounded for reads, which is unfortunately what we are doing.  Remember, reads are generally synchronous while writes are asynchronous.  This only compounds the problem, serializing each read, and contributing to program latency.
    </para>
</chapter>
