I am working on a system that requires high file I / O functionality (with C #). Actually, I'm flooding large files (~ 100 MB) from the start of the file till the end of the file. Every 5 seconds I'm adding 5 MB (sequentially from the beginning of the file) in the file, I am flush stream on every bulk. Every few minutes I need to update a structure that I write at the end of the file (some kind of metadata).
When there is a flush in each bulk, then I have no performance problem. However, when updating metadata at the end of the file, I actually get fewer performance. My guess is that when the file is created (which should also be made extra fast), the file does not actually assign the entire 100 MB to the disk and when I flush the metadata it allocates all the locations till the end of the file Have to do
People / girls, any ideas how can I overcome this problem?
Thanks a lot!
From the comment:
The code is as follows, the first file is opened:
m_stream = new filestream (filename, file md.create new Write file, write file, file share, type 8192, incorrect); M_Stream.SetLength (100 * 1024 * 1024);
writing every few seconds ~ 5 MB
m_stream.Seek (m_LastPosition, SeekOrigin.Begin); M_stream.write (buffer, 0, buffer length); M_Stream.Flush (); M_LastPosition + buffer.lambi; // hh: Guessed + m_Stream.Seek (mMetaDataSize, SeekOrigin.End); M_Stream.Write (metadata, 0, metadata lang); M_Stream.Flush (); // takes a very long time for the first time (~ 1 second). As suggested above, it will not be understandable (assuming that you have the meta data I should end the file) write that. It will handle 2 things (a non-sparse file) ... 1. Allocate total space for the entire file 2. Any of the following writing operations is slightly faster like space is ready and waiting Used to be.
Can not you do this incomparable? At least this app can proceed to other things.
Comments
Post a Comment