Java Reference
In-Depth Information
In exchange for reduced storage costs, persistence, and portability, secondary
storage devices pay a penalty in terms of increased access time. While not all ac-
cesses to disk take the same amount of time (more on this later), the typical time
required to access a byte of storage from a disk drive in 2011 is around 9 ms (i.e.,
9 thousandths of a second). This might not seem slow, but compared to the time
required to access a byte from main memory, this is fantastically slow. Typical
access time from standard personal computer RAM in 2011 is about 5-10 nanosec-
onds (i.e., 5-10 billionths of a second). Thus, the time to access a byte of data from
a disk drive is about six orders of magnitude greater than that required to access a
byte from main memory. While disk drive and RAM access times are both decreas-
ing, they have done so at roughly the same rate. The relative speeds have remained
the same for over several decades, in that the difference in access time between
RAM and a disk drive has remained in the range between a factor of 100,000 and
1,000,000.
To gain some intuition for the significance of this speed difference, consider the
time that it might take for you to look up the entry for disk drives in the index of
this topic, and then turn to the appropriate page. Call this your “primary memory”
access time. If it takes you about 20 seconds to perform this access, then an access
taking 500,000 times longer would require months.
It is interesting to note that while processing speeds have increased dramat-
ically, and hardware prices have dropped dramatically, disk and memory access
times have improved by less than an order of magnitude over the past 15 years.
However, the situation is really much better than that modest speedup would sug-
gest. During the same time period, the size of both disk and main memory has
increased by over three orders of magnitude. Thus, the access times have actually
decreased in the face of a massive increase in the density of these storage devices.
Due to the relatively slow access time for data on disk as compared to main
memory, great care is required to create efficient applications that process disk-
based information. The million-to-one ratio of disk access time versus main mem-
ory access time makes the following rule of paramount importance when designing
disk-based applications:
Minimize the number of disk accesses!
There are generally two approaches to minimizing disk accesses. The first is
to arrange information so that if you do access data from secondary memory, you
will get what you need in as few accesses as possible, and preferably on the first
access. File structure is the term used for a data structure that organizes data
stored in secondary memory. File structures should be organized so as to minimize
the required number of disk accesses. The other way to minimize disk accesses is to
save information previously retrieved (or retrieve additional data with each access
at little additional cost) that can be used to minimize the need for future accesses.
Search WWH ::




Custom Search