3

Good afternoon,

I inherited some C# code from years ago. I have refactored it a bit to be asynchronous. Evaluating the impact of my changes on the performance of the CPU, I used Process Explorer to watch, roughly, what my app was doing. To my surprise, it appears to be doing what Process Explorer reports as I/O. In general, this is related to Disk I/O or Network I/O. Based on what I can see of the code, I can't figure out an explicit call to either of those 2 I/O sources.

My question is: what is the best way to identify which section of code is causing I/O? We use dotTrace from JetBrains to profile our application, but, from what I can tell, it only handles CPU and Memory performance.

Thanks in advance for any pointers.

Regards,

Eric.

Eric Liprandi
  • 5,324
  • 2
  • 49
  • 68

4 Answers4

5

Process Monitor may be your answer. Refer to the following StackOverflow question for more information.

How can I profile file I/O?

Building on that answer, you may be able to search your solution for the filename of any commonly read or written files found with Process Monitor.

Community
  • 1
  • 1
Thomas Langston
  • 3,743
  • 1
  • 25
  • 41
  • +1. I find the Process Activity Summary function invaluable for seeing at a glance which files are being accessed the most. – the_mandrill Nov 03 '10 at 22:28
  • Thanks a lot. While it didn't show which part of my code was doing it, as soon as I saw which file was being accessed, I nailed it. Appreciate the help. – Eric Liprandi Nov 03 '10 at 23:53
2

The stackshot method, also called random pausing, will find it, if it takes significant time.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
1

If the I/O code is managed, you can load the symbols for the .net framework and set breakpoints in crucial functions (e.g. FileStream constructors etc.)

It involves some guess work but can be informative if you succeed.

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
0

In addition to Process Monitor, I find the Resource Monitor on Win7 (also available under 'Performance and Reliability' I think on Vista) very useful for diagnosing I/O-related slowdowns. Switch to the disk view and sort by Read/Write or Total (win7 only). Also keep an eye on the list of files that appear.

the_mandrill
  • 29,792
  • 6
  • 64
  • 93