Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: A nasty inefficieny in file.c?

Re: A nasty inefficieny in file.c?

From: Jens Arnold <arnold-j_at_t-online.de>
Date: Fri, 14 Jul 2006 08:06:22 +0200

On 14.07.2006, postmaster_at_diffenbach.org wrote:

> Jens Arnold wrote:
>> For this purpose, file.c caches up to one sector worth of
>> data. "headbytes" is any new data that fits into the sector
>> cache when it's already dirty.

> That implies thst the file is being /written/ to disk? What's
> being written when I'm just listening to music?

Hmm, my description was a little imprecise. readwrite() is
used for both reading and writing, that's why it's called
"readwrite()". It divides every file access in 3 parts:

(1) Head bytes. These are any bytes copied to / from the
    sector cache when the cache already contains something.
    When the sector cache becomes full / completely used, it
    is marked empty (after flushing to disk for writing).

(2) Whole sectors. These are written to / read from disk
    without extra caching.

(3) Tail bytes. These are any leftover bytes which don't fill
    up a whole sector, and are copied to / from the sector
    cache (after filling the cache from disk for reading).

So, if a file is read or written in single-byte calls, there'll
be 1x one tail byte and 511x one head byte for each 512 bytes of
data. Very inefficient.


Regards, Jens
Received on 2006-07-14

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy