flat assembler
Message board for the users of flat assembler.
Index
> Windows > Simple program taking an extremely long time to complete |
Author |
|
l_inc 06 Aug 2015, 22:54
magicSqr
Quote: The problem is, it creates, fills and closes the first file in 1 second, sometimes it does the same for the 2nd and the 3rd can take upto 5 minutes to complete. Takes 0.6 seconds for all three for me. But... Quote: It seems like a massive memory leak but if it is I can't find it. There's no memory leak. Though you're stressing the cache manager extremely. As soon as it reaches its working set limits, which might happen after you've written one file or two or three..., the system starts actively paging the file data in relatively little chunks, and not only of the files your code writes, but also of other system components including kernel and drivers data. The result is thrashing. The file mapping solution here is a quite inefficient one. So there are multiple things you could do about the lags you experience. The most simple one is to just specify FILE_FLAG_SEQUENTIAL_SCAN for the CreateFile call. This should reduce the amount of memory the cache manager uses for the files. The most efficient solution would be however to store the data in chunks of 4 or 8 megabytes into a single region of private virtual memory (VirtualAlloc) of that size and write those chunks simply with WriteFile into files opened with FILE_FLAG_NO_BUFFERING+FILE_FLAG_WRITE_THROUGH. You can create the files even faster if you parallelize data storage and data generation by doing overlapped I/O, in which case you'd need at least 2 regions of private virtual memory of 4/8 MB, but that's gonna make the code a bit more complicated and wouldn't give much, because your data generation is in the order of a fraction of a percentage point of the time needed to store the data to the drive, especially if it's not an SSD. _________________ Faith is a superposition of knowledge and fallacy |
|||
06 Aug 2015, 22:54 |
|
magicSqr 10 Aug 2015, 22:06
Thanks l_inc, I hadn't considered the cache angle. I'll check out which of your methods works best for my problem.
Quote:
ggrrrrr lol |
|||
10 Aug 2015, 22:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.