0

I have a web application in C# that creates a file stream and then sequentially reads and processes rather large text files from the server. This process is currently very slow.

I've heard about memory-mapped files in C#. My question is: would it be faster to do that process if the file was entirely mapped to memory? Also, what are the other advantages/disadvantages of that?

Fernando Aires Castello
  • 1,203
  • 3
  • 17
  • 23
  • 2
    Depends on what you're doing with the files. Without any information as to what you're doing, we really couldn't say. – Servy Oct 31 '13 at 21:07
  • We only read data from the files, they are plain-text files that contain telephone billing information. We have to read ints, doubles, strings, etc. and process all that information. – Fernando Aires Castello Oct 31 '13 at 21:11
  • Then it's likely not going to help at all. – Servy Oct 31 '13 at 21:12
  • Assuming you are currently reading the files sequentially and each "line" is exclusive, you could chunk the files and use multiple worker threads to process the files quicker. Outside that, you don't have many other options. – Xenolightning Oct 31 '13 at 21:31
  • I would suggest narrowing down what exactly makes the process slow. Maybe processing is slow because you cannot read faster from the drive than you already do. If so starting multiple threads and chunking the file would not help at all. How do you open the file for reading? You can use the file options to enforce optimized read ahead strategies in the operating system [FileOptions Enumeration](http://msdn.microsoft.com/en-US/library/system.io.fileoptions%28v=vs.110%29.aspx) – Markus Safar Oct 31 '13 at 23:35

0 Answers0