C#: File access slows when 2 files are accessed at same time.  
Author Message
BioSlayer





PostPosted: Visual C# General, C#: File access slows when 2 files are accessed at same time. Top

I am writing an application that will have a client and server. For now I am developing the program on a single computer right now (so both client and server are the same machine and in the same application domain). The application has the server and client access a file at the same time (both files size are around 100 Mb) They read the entire file strait through in half Mb chunks. If I have the application access the files at the same time it will run around 42 seconds to do its processing. If I have one access the file only after the other is done then it takes about 7 seconds to complete. That’s a 6x speed hit.

Anyone have any idea why this happens

I want to make it so they will access their individual files at the same time without having any speed hits. Anyone know what I can do



Visual C#1  
 
 
louthy





PostPosted: Visual C# General, C#: File access slows when 2 files are accessed at same time. Top

You're thrashing the buffers to/from the disk, try setting the source and destination to different drives.  You may also want to try a lower buffer size in your app.  1/2 mb seems a little high to me.  Experiment with values of 1k and upwards.
 
 
BioSlayer





PostPosted: Visual C# General, C#: File access slows when 2 files are accessed at same time. Top

I figured as much. Unfortunately the machine I’m writing it on has only one hard drive. The program is similar to bit-torrent (meant to copy files over the network), so the likely hood of it running in a similar environment once it’s in production is very low. Thanks for your quick reply though.