Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting at the end of file
    primarykey
    data
    text
    <p>I'm working on a system that requires high file I/O performance (with C#). Basically, I'm filling up large files (~100MB) from the start of the file until the end of the file. Every ~5 seconds I'm adding ~5MB to the file (sequentially from the start of the file), on every bulk I'm flushing the stream. Every few minutes I need to update a structure which I write at the end of the file (some kind of metadata).</p> <p>When flushing each one of the bulks I have no performance issue. However, when updating the metadata at the end of the file I get really low performance. My guess is that when creating the file (which also should be done extra fast), the file doesn't really allocates the entire 100MB on the disk and when I flush the metadata it must allocates all space until the end of file.</p> <p>Guys/Girls, any Idea how I can overcome this problem?</p> <p>Thanks a lot!</p> <p>From comment:</p> <p>In general speaking the code is as follows, first the file is opened: </p> <pre><code>m_Stream = new FileStream(filename, FileMode.CreateNew, FileAccess.Write, FileShare.Write, 8192, false); m_Stream.SetLength(100*1024*1024); </code></pre> <p>Every few seconds I'm writing ~5MB. </p> <pre><code>m_Stream.Seek(m_LastPosition, SeekOrigin.Begin); m_Stream.Write(buffer, 0, buffer.Length); m_Stream.Flush(); m_LastPosition += buffer.Length; // HH: guessed the += m_Stream.Seek(m_MetaDataSize, SeekOrigin.End); m_Stream.Write(metadata, 0, metadata.Length); m_Stream.Flush(); // Takes too long on the first time(~1 sec). </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload