I am developing an application in which i store my temporary data on hard disk(in file of size in MBs). This file is frequently accessed. I am hoping that by allocating the file contiguously it will result in improved performance.
Is it possible to explicitly force the system to allocate file block contiguously?
Thank you
Not really.
On Jan 14, 2008 1:18 PM, wrote:
> I am developing an application in which i store my temporary data on hard
> disk(in file of size in MBs). This file is frequently accessed. I am hoping
> that by allocating the file contiguously it will result in improved
> performance.
>
> Is it possible to explicitly force the system to allocate file block
> contiguously?
>
> Thank you
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@hollistech.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
–
Mark Roddy
If you really want to do this, you could something like allocate and
then defragment, but that seems unlikely to pay off.
mm
Mark Roddy wrote:
Not really.
On Jan 14, 2008 1:18 PM, > mailto:xxxxx> wrote:
>
> I am developing an application in which i store my temporary data on
> hard disk(in file of size in MBs). This file is frequently accessed.
> I am hoping that by allocating the file contiguously it will result
> in improved performance.
>
> Is it possible to explicitly force the system to allocate file block
> contiguously?
>
> Thank you
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@hollistech.com
> mailto:xxxxx
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> mailto:xxxxx
>
>
>
>
> –
> Mark Roddy</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>
We’ve had to do this ourselves a few times.
The way you can REQUEST a file be as unfragmented as possible from your application is to open the file, and then seek to and write the LAST location of the file. That’ll cause the FS to at least attempt a best-effort contiguous allocation.
After that, you’ll need to check to see if the file is contiguous and if not, manually defrag it. You can Google FSCTL_GET_RETRIEVAL_POINTERS to get some hints to the API to use (including a rather old but very helpful article and example by Mark Roddy).
Peter
OSR
I’ve frequently wondered if the OP of this and similar questions has
actually determined that it is disk block fragmentation that is the
bottleneck in his or her application, or has just been told to make it
faster and has no idea what else to change.
On Jan 14, 2008 2:26 PM, Martin O’Brien wrote:
> If you really want to do this, you could something like allocate and
> then defragment, but that seems unlikely to pay off.
>
> mm
>
> Mark Roddy wrote:
> > Not really.
> >
> > On Jan 14, 2008 1:18 PM, > > mailto:xxxxx> wrote:
> >
> > I am developing an application in which i store my temporary data on
> > hard disk(in file of size in MBs). This file is frequently accessed.
> > I am hoping that by allocating the file contiguously it will result
> > in improved performance.
> >
> > Is it possible to explicitly force the system to allocate file block
> > contiguously?
> >
> > Thank you
> >
> > —
> > NTFSD is sponsored by OSR
> >
> > For our schedule debugging and file system seminars
> > (including our new fs mini-filter seminar) visit:
> > http://www.osr.com/seminars
> >
> > You are currently subscribed to ntfsd as: xxxxx@hollistech.com
> > mailto:xxxxx
> > To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> > mailto:xxxxx
> >
> >
> >
> >
> > –
> > Mark Roddy
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> You are currently subscribed to ntfsd as: xxxxx@hollistech.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
–
Mark Roddy</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>
You’re absolutely right.
If I had actually READ his question completely, I wouldn’t have bothered to answer him (thus potentially prolonging his pain). We’ve had to create contiguous disk files lots o times, but the issue certainly was never “to make my application be able to read them faster”
That’ll teach me to read the WHOLE question, not just the first and last sentence 
Peter
OSR
But.
If an application knows the size of the file it is going to generate, doing a SetEof() upfront and forcing allocation upfront, helps quite a bit in ensuring fragmentation is minimized, instead of just using extending writes. No guarantees of ‘contiguous allocation’ are given out, but it is a good optimization in general. Many applications play this right, including a bunch of system APIs. This is the cheapest thing one can do to keep the FS from being fragmented.
Ravi
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com [xxxxx@osr.com]
Sent: Monday, January 14, 2008 3:02 PM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Contiguous file allocation
You’re absolutely right.
If I had actually READ his question completely, I wouldn’t have bothered to answer him (thus potentially prolonging his pain). We’ve had to create contiguous disk files lots o times, but the issue certainly was never “to make my application be able to read them faster”
That’ll teach me to read the WHOLE question, not just the first and last sentence 
Peter
OSR
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
IIRC ZwCreateFile (unlike CreateFile) supported providing the file size to
the file creation call.
Will this result in non-fragmented file?
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
“Ravi Pudipeddi” wrote in message
news:xxxxx@ntfsd…
But.
If an application knows the size of the file it is going to generate, doing a
SetEof() upfront and forcing allocation upfront, helps quite a bit in ensuring
fragmentation is minimized, instead of just using extending writes. No
guarantees of ‘contiguous allocation’ are given out, but it is a good
optimization in general. Many applications play this right, including a bunch
of system APIs. This is the cheapest thing one can do to keep the FS from being
fragmented.
Ravi
________________________________________
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On
Behalf Of xxxxx@osr.com [xxxxx@osr.com]
Sent: Monday, January 14, 2008 3:02 PM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Contiguous file allocation
You’re absolutely right.
If I had actually READ his question completely, I wouldn’t have bothered to
answer him (thus potentially prolonging his pain). We’ve had to create
contiguous disk files lots o times, but the issue certainly was never “to make
my application be able to read them faster”
That’ll teach me to read the WHOLE question, not just the first and last
sentence 
Peter
OSR
—
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
I’d recommend SetEof/ZwSetInformationFile over the allocation size passed in CreateFile.
That will be released if you don’t use it up - i.e. advance the eof - by handle close. It is useful if you need some guaranteed atomicity in the allocation with the create which has dubious value, but also brings some unknowns into the picture.
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih [xxxxx@storagecraft.com]
Sent: Tuesday, January 15, 2008 3:41 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] RE:Contiguous file allocation
IIRC ZwCreateFile (unlike CreateFile) supported providing the file size to
the file creation call.
Will this result in non-fragmented file?
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
“Ravi Pudipeddi” wrote in message
news:xxxxx@ntfsd…
But.
If an application knows the size of the file it is going to generate, doing a
SetEof() upfront and forcing allocation upfront, helps quite a bit in ensuring
fragmentation is minimized, instead of just using extending writes. No
guarantees of ‘contiguous allocation’ are given out, but it is a good
optimization in general. Many applications play this right, including a bunch
of system APIs. This is the cheapest thing one can do to keep the FS from being
fragmented.
Ravi
________________________________________
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On
Behalf Of xxxxx@osr.com [xxxxx@osr.com]
Sent: Monday, January 14, 2008 3:02 PM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Contiguous file allocation
You’re absolutely right.
If I had actually READ his question completely, I wouldn’t have bothered to
answer him (thus potentially prolonging his pain). We’ve had to create
contiguous disk files lots o times, but the issue certainly was never “to make
my application be able to read them faster”
That’ll teach me to read the WHOLE question, not just the first and last
sentence 
Peter
OSR
—
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com