# Disk Seeks Considered Harmful

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:

- Placing lots of small files all over the disk.

- Opening, stating, and reading lots of files all over the disk

- 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.

- 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.

- Repeatedly doing the above when it only needs to be done once.

Mögliche Wege, wie Sie Ihren Code suchfreundlich optimieren können:

- Fassen Sie Daten in einer einzigen Datei zusammen.

- Halten Sie Daten im gleichen Ordner vor.

- Speichern Sie Daten zwischen, so dass sie nicht fortwährend erneut eingelesen werden müssen.

- Geben Sie Daten frei, so dass sie nicht beim Laden von Anwendungen immer wieder erneut gelesen werden müssen.

- Erwägen Sie, alle Daten in einer einzigen Binärdatei zwischenzuspeichern, die sauber aufgebaut ist und mit mmap verarbeitbar ist.

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.