Application is slow while writing data in to text files.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pandiankk
    New Member
    • Jul 2010
    • 2

    #1

    Application is slow while writing data in to text files.

    Hello,
    I am having a performance issue with one of my C#.NET console application. The application is faster(takes 10 mins) when it runs from our test environment, but slower on Production environment(tak es 80 mins). The settings/Configurations are same between the two environments.Th e application reads a text file, which has 180K records, and splits it up into multiple text file based on a condition. I am attaching the code with this. Please give your valuable suggestions and help me resolve this.
    In the sample code, I have used stream writer to write in to files. I tried with File.AppendText , BinaryWriter etc. But no change in the performance.
    Thanks
    Attached Files
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    I invite anyone to correct me if I am wrong, but when we start talking about access times for file reads/writes there are a lot of possible causes including hardware.

    Are you using the same .Net framework version in test and production? How does your test hardware compare to your production hardware? Are you using a local disk in your test environment and not in production? If you are using a local disk in production, is the disk slower in production than in test? How busy is production as compared to test? Is your production server loaded down with other processes and services or are there any other processes which have a lot of file I/O accessing the same disk?

    Comment

    • Pandiankk
      New Member
      • Jul 2010
      • 2

      #3
      Thanks for your quick response. Both the servers have same same version of framework(2.0), OS,service packs installed. Both READ and WRITE operation is done on local disks on both the servers. Production server will be busy between 2 and 5 pm and this application is being executed in the morning. I don't see any other services, processes that do I/O operations or are memory/CPU expensive.
      I checked with Infrastructure team and they said that both the servers are same in terms of hardware configuration and settings. I have no clue at all. Perhaps, Did i miss any settings in the application properties for it to run slower?

      Thanks

      Comment

      • Tony Grimshaw

        #4
        Joseph

        I am having similar problems writing to a server. I think we have hardware problems. But there seems to be a major bottleneck in allocating space in windows server for a new file or extending old ones. So I tried the following experiment.

        I preallocated the space for the file. In the language I am using this means writing record number 180000 before record 1. This forces windows to allocate all the space needed for the file in one step. I then wrote 180000 records of 256 bytes each. It took two minutes! Letting Windows allocate the space as and when needed this exercise would have taken 480 minutes on the system we have.

        If you found another solution I would be interested

        Regards

        Tony Grimshaw

        Comment

        Working...