MooseFET said:
Sequentially means one after the other on the media. Disks are rarely
used this way. Things are usually written in sectors. The sectors
may not be in order. Normally you don't see this when you read and
write because the OS hides this from you.
I assume when I tell the OS to write a file sequentially it will do it's
best to do so.
If you believe this is not the case then you will have to proof that
If you simply allow the OS to work with the data as a single flat
structure you may have one entry that is partly on one sector and
partly on another. This means that to seek to that element and read
it, two sectors must be read. You will take a major speed hit if you
allow that to happen.
Most sectors are 512 bytes, so 64 pairs of integer and pointer will fit in
it.
Worst case scenerio would be a little offset, so than 62 pairs would fit in
it.
Also harddisks are pretty smart.
The chance is big they will read the next sector and cache the previous
sector anyway.
So no additional seeks are needed if the data happens to spill over onto the
previous or next sector.
Worst case scenerio sectors are somewhere else, which means 1 full read for
the 62 pairs. 1 read for the previous spilling
1 read for the next spilling.
However since the fill was written sequantially, the next integers and
previous ones will be cached/read/write as well.
So these can all be considered full reads.
Which means the spilling onto different sectors doesn't really have to be a
problem.
Which means the file fragmentation is the only real problem.
Bye,
Skybuck.