News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Best size for I/O buffer

Started by sinsi, March 11, 2013, 01:37:16 PM

Previous topic - Next topic

sinsi

I have my disc imaging program working OK, just wondering what would be the best buffer size for reading a CD/DVD.
I am opening a volume, using "\\.\D:", should I use FILE_FLAG_SEQUENTIAL_SCAN? Not sure if they work on discs.
Tá fuinneoga a haon déag níos fearr :biggrin:

hutch--

sinsi,

usually the seek time on a CD is reasonably slow alongside a hard disk so I would be inclined to use a very large IO buffer but be willing to try different sizes to see what works best. It has a lot to do with the internals of the API you want to use as to whether it uses an internal buffer of a limited size like 8 or 16k. If so a small buffer would probably work best but I would time it as there may not be much documentation on how the API internals work.

dedndave

if i remember, CD's are divided into 2 kb chunks (you may want to check that - lol)
the disk cluster may be 8 kb, 16 kb, and so on
so, some multiple of the disk cluster would seem logical

http://support.microsoft.com/kb/98756

sinsi

Using a 2KB buffer took 5 minutes to copy 650MB, a 1MB buffer took 3 minutes.
I might rewrite it in 64-bit and use a buffer the size of the disc, see how that goes.
Tá fuinneoga a haon déag níos fearr :biggrin:

dedndave

you may want to write it so you can try several buffer sizes   :P
of course, it could do the first several buffer read.writes with different buffer sizes
then, select the one that was fastest for the rest of the copy process

Magnum

Three minutes is pretty fast for making a CD.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

sinsi

No real difference between loading the whole disc and using a 1MB buffer, both around 3 minutes.
Really, not much difference between 64KB and 1MB.
Using a buffer also allows for user feedback without all the trouble of overlapped I/O.

Andy, it's not burning a CD, just reading it to a .iso file.
Good for use with VMs and now with Windows 8 - you just mount the disc as a drive.
It's a better way of backing up a disc too, no more scratches.
Tá fuinneoga a haon déag níos fearr :biggrin:

Tedd

I find a 4MB buffer usually works quite well for straight copying, though I haven't tried it with a CD/DVD.
FILE_FLAG_SEQUENTIAL_SCAN is a caching hint, so it won't have a huge effect in this case, but it won't hurt either.

The CD drive has its own internal buffer, so your aim is really to ensure that can be emptied and refilled as quickly as possible; once that's satisfactory, increasing your buffer size further will probably have little effect.
Of course, the best way to find out is to test various sizes with different settings - find the size of the CD drive buffer, and then try 1/2, 1, 2, 4 as multiples  ;)
Potato2