Buffer size

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Buffer size

Post by frank »

I have recently been reevaluating my filesystem and disk drive interface. Right now my buffer sizes are as follows

Hard Disks: 128kb
Floppy Disks: ~90kb

I was just wondering if these sound a little small or a little big, by the way these numbers are per drive. Also what is a good size for the buffers for the filesystems.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

buffer size depends on the filesystem as well: IIRC systems like XFS tends to use far larger buffers than FAT (due to scheduling). Also, you can use unused memory as disk cache: i.e. increase the buffer size when lots of memory is available, and decrease it when memory becomes scarce.
</theoretical rambling>
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Is that in-kernel buffering, or user-space buffering?

The latter can be controlled from user-space using setvbuf(), with the default size being defined as BUFSIZ. Both declared in <stdio.h>. Here (x86 Linux), BUFSIZ is 8k.
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

No thats for the in-kernel buffers for the disk drives. I was just wondering if that size sounds ok.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

The DMA buffer for a floppy drive maxes out at one page (=64K). However, the floppy can really only transfer one cylinder at a time (= 18 sectors = 9k). Two 9K buffers = 18K ought to cover any possible floppy transfer.

For a hard disk, I think 128K to 1M for the total buffer space sounds fine. Memory is precious, but the data comes off a drive pretty fast, and your kernel really can't service it all THAT often.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

bewing wrote:The DMA buffer for a floppy drive maxes out at one page (=64K). However, the floppy can really only transfer one cylinder at a time (= 18 sectors = 9k). Two 9K buffers = 18K ought to cover any possible floppy transfer.

For a hard disk, I think 128K to 1M for the total buffer space sounds fine. Memory is precious, but the data comes off a drive pretty fast, and your kernel really can't service it all THAT often.
Ok, then I guess my next question is, how do I make the hard drive and floppy drive accesses faster? I already use DMA on the floppy drive and I haven't messed with any thing on the hard drive(other than reseting it).
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

DMA on a floppy is as fast as it gets. Floppies are dead slow devices -- that's why we all hate them.

For standard P-ATA disk drives, your speed improvement steps are going to be UDMA and then ADMA -- both used only with multitasking. But ADMA is only supported on ATA-6 drives, I think.
Post Reply