How to allocate contiguous disk space?

I am developing a system that works with a large number of files and performs some Google search queries, which I read about improving the speed of finding information on the hard drive. But since I work with Java, I can not find any library to work with this problem. I have very vague C ++ knowledge and found something about finding hard drive information using IOCTL . Apparently, there is no way to get specific information, for example, how many contiguous free blocks can be obtained from my hard drive or the maximum of contiguous free blocks that it has. I am currently working with Windows 7 and XP. I know about using JNI, but I have serious problems with C ++. But even for finding solutions in C ++, I cannot find anything. Maybe I'm doing the wrong queries on Google. Can someone please give me a link, study suggestions or something else? I am ready to learn C ++ (although I have almost no free time).

Thank you very much!

PS-Edit: I know, it didn't really matter. But I really need to find out about this. But thanks to everyone who gives advice.

+4
source share
4 answers

Have you identified a performance issue? If not, do nothing.

Are you sure that the physical distribution of files on disk is the cause of this performance problem? If not, then measure where the time is spent in your application, and try to improve the algorithms, if necessary, enter caches.

If you have done all this and are confident in the physical distribution of files on the disk that cause performance problems, have you considered buying a faster disk or using several? Hardware is often much cheaper than development time.

I highly doubt that the physical distribution of files on disk has a significant impact on the performance of your application. First, I would search elsewhere.

+8
source

AFAIK there is no built-in method and 100% pure Java solution. The problem is that obtaining such information is platform dependent, and since Java must be platform independent, you can use only one subset.

+1
source
Captain Kernel explains here that this will not necessarily lead to an increase in disk performance, and also, it is impossible without a lot of work.
+1
source

NTFS is already trying to distribute your files contiguously, as indicated in this post on the Windows 7 Engineer Blog . Your files will only be fragmented if there is not enough large contiguous part of the free space.

If you think it is important that your files are not fragmented, I think the best option is to schedule nightly defragmentation of your disk. This is more of a system administration problem.

Finally, fragmentation is not related to SSDs .

+1
source

Source: https://habr.com/ru/post/1342053/


All Articles