© J.C. Kessels 2009
MyDefrag Forum
May 25, 2013, 02:36:33 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
MyDefrag Forum
>
JkDefrag v3 Forum
>
Programming with the library
>
Creating a contiguous file
Pages: [
1
]
« previous
next »
Print
Author
Topic: Creating a contiguous file (Read 17094 times)
GrosM
Newbie
Posts: 4
Creating a contiguous file
«
on:
October 21, 2007, 08:13:13 am »
Hello everyone !
I love this utility, code is clear and gave me better understanding of how to control fragmentation on my disk.
However, I'd like to go further by being able to create a file of a certain size, unfragmented. The only solution I found so far is to create the file, write my data and defragment it, which is indeed costly.
Does anybody knows if there are any system calls that can be used to allocate several contiguous clusters to a newly created file ? I looked up MSDN without any luck...
Thanks !
GM.
Logged
GippleDocks
JkDefrag Supporter
Posts: 13
Creating a contiguous file
«
Reply #1 on:
October 22, 2007, 11:56:39 am »
I think Syinternals's contig utility with the '-n' parameter will do it. See
http://www.microsoft.com/technet/sysinternals/utilities/contig.mspx
.
Logged
GrosM
Newbie
Posts: 4
Creating a contiguous file
«
Reply #2 on:
October 22, 2007, 04:55:10 pm »
Yes, that's what I'm doing now : launching the process "contig.exe" and then writing on it, but this process creation is rather slow compared to coding it myself. Besides, I'm not sure that it doesn't do the same : creating the file, fixing its length and defragmenting it.
I couldn't find the source code of Contig, I'm not sure it's open source but I'll check on it.
If someone has it though, I'd be interested !
Thanks !
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Creating a contiguous file
«
Reply #3 on:
October 22, 2007, 06:43:33 pm »
Quote from: "GrosM"
Does anybody knows if there are any system calls that can be used to allocate several contiguous clusters to a newly created file ?
Take a look at the FSCTL_SET_ZERO_DATA control code. It does not guarantee contiguous clusters, but since it is a very low-level function call it is extremely fast, and since you specify the size of the file it "knows" how big the new file must be, and can theoretically use that information to create a unfragmented file. I think it's the closest you can get to pre-allocating a file in Windows.
Logged
GrosM
Newbie
Posts: 4
Creating a contiguous file
«
Reply #4 on:
November 04, 2007, 11:44:56 pm »
Thanks, I'll give it a try if I have some time. It sound promising along with the registry key "ContigFileAllocSize".
Thank you !
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Creating a contiguous file
«
Reply #5 on:
November 05, 2007, 01:34:21 am »
Quote from: "GrosM"
registry key "ContigFileAllocSize"
I didn't know that key! Sounds interesting. I wonder if it can be changed on-the-fly, or wether you have to reboot after changing it. Also I wonder which Windows versions support it, I haven't found any Microsoft docs. And I think you will get a disk full error if no gap is big enough, which may happen even though there is plenty of free space.
Logged
GrosM
Newbie
Posts: 4
Creating a contiguous file
«
Reply #6 on:
November 05, 2007, 12:33:43 pm »
From what I read on the Internet (as you said, no Microsoft documentation was found), you should change the value, defrag and reboot, which would make it not very dynamic.
If you know the average file size (and in my case, I know), you can set it up to decrease fragmentation. I have read that people put it at 0x200 (512 kb) and had great result with Windows XP.
I tried 0x1000 (4 Mb) on 2003 Server and it didn't work so fine. It seems that file fragmentation was low but directory fragmentation was very high.
Logged
Myriades
JkDefrag Hero
Posts: 169
Creating a contiguous file
«
Reply #7 on:
November 05, 2007, 01:14:54 pm »
Hi all
i've found doc under microsoft technet ( windows 98 )
Quote
HKEY_LOCAL_MACHINE \System \CurrentControlSet \Control \FileSystem
An additional performance setting in the FileSystem subkey, ContigFile AllocSize, can be used to change the size of the contiguous space that VFAT searches for when allocating disk space. Under MS-DOS, the file system began allocating the first available space found on the disk, which ensured a great deal of disk fragmentation and related performance problems. By default under Windows 98, VFAT first tries to allocate space in the first contiguous 0.5 MB of free space and then returns to the MS-DOS method if it cannot find at least this much contiguous free space. This optimizes performance for both the swap file and multimedia applications.
In some cases, you might choose to set a smaller value in the registry, as when you are not running demanding applications on the computer. A smaller value for ContigFileAllocSize, however, can lead to more fragmentation on the disk and, consequently, more disk access for the swap file or applications that require larger amounts of disk space.
it seems that only vfat filesystem is concerned
Logged
Try the
jkdefrag installer v1.8.3.36
Related topic
Astroman
JkDefrag Hero
Posts: 88
Re: Creating a contiguous file
«
Reply #8 on:
November 20, 2007, 05:57:14 am »
I use this computers I work on, and have for quite some time, part of my tweaks.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"NtfsDisableLastAccessUpdate"=dword:00000000
"NtfsDisable8dot3NameCreation"=dword:00000001
"NtfsMftZoneReservation"=dword:00000001
"ContigFileAllocSize"=dword:00000200
Logged
Lexar
JkDefrag Hero
Posts: 91
Re: Creating a contiguous file
«
Reply #9 on:
December 10, 2007, 05:31:35 am »
Just happened to come across:
BizTalk Server Database Optimization
Quote
ContigFileAllocSize | Adjusts the minimum contiguous file allocation to 64KB; this is generally only for database servers, and should be used with great caution as it can cause servers with heavy small file traffic to quickly fill disks. On the positive side, it significantly reduces fragmentation of data files by forcing larger contiguous allocations.
Looks like it's not only for VFAT, though I am not sure if it works on WinXP.
Logged
Lexar
JkDefrag Hero
Posts: 91
Re: Creating a contiguous file
«
Reply #10 on:
December 10, 2007, 07:25:51 am »
And to my chagrin, it didn't work on NTFS under Windows XP. I set the value to 1024(0x400), copied a small file and a somewhat larger file to another location and checked if they are less fragmented than 1024KB per fragment, to a disappointing result:
Code:
Bytes: 81276
Clusters: 20
Fragments: 5
File system: NTFS
Compressed: No
Modified: 10.12.2007 15:08
Code:
Bytes: 36668736
Clusters: 8953
Fragments: 53
File system: NTFS
Compressed: No
Modified: 10.12.2007 15:12
Logged
jeroen
Administrator
JkDefrag Hero
Posts: 7155
Re: Creating a contiguous file
«
Reply #11 on:
December 10, 2007, 07:43:25 am »
Quote from: Lexar on December 10, 2007, 07:25:51 am
it didn't work on NTFS under Windows XP.
Did you reboot after changing the setting?
Logged
Lexar
JkDefrag Hero
Posts: 91
Re: Creating a contiguous file
«
Reply #12 on:
December 10, 2007, 10:42:08 am »
Quote from: jeroen on December 10, 2007, 07:43:25 am
Quote from: Lexar on December 10, 2007, 07:25:51 am
it didn't work on NTFS under Windows XP.
Did you reboot after changing the setting?
Yes, I did so. It didn't work on NTFS under plain Windows XP Home Edition.
Looks like I will still need your JkDefrag v4.0 very much.(^^)
Logged
controller
Newbie
Posts: 1
Re: Creating a contiguous file
«
Reply #13 on:
September 01, 2008, 08:27:25 am »
i found out there are two of these "ContigFileAllocSize" registry entries
Code:
Windows Registry Editor Version 5.00
; set ContigFileAllocSize to 64Kb
; one for w98 and one for winxp
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"ContigFileAllocSize"=dword:00000040
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"ContigFileAllocSize"=dword:00000040
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
MyDefrag v4 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Scripts, and other contributions
-----------------------------
JkDefrag v3 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Programming with the library
Loading...