如何找出应用程序中导致 I/O 的原因?
下午好,
我继承了多年前的一些 C# 代码。我将其重构为异步的。 为了评估我的更改对 CPU 性能的影响,我使用了 Process Explorer 粗略地观察我的应用程序正在做什么。 令我惊讶的是,它似乎正在执行 Process Explorer 报告的 I/O 操作。一般来说,这与磁盘 I/O 或网络 I/O 有关。 根据我所看到的代码,我无法找出对这两个 I/O 源中任何一个的显式调用。
我的问题是:识别哪段代码导致 I/O 的最佳方法是什么?我们使用 dotTrace 来自 JetBrains 来分析我们的应用程序,但是,据我所知,它只处理 CPU 和内存性能。
预先感谢您的任何指点。
问候,
埃里克。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
进程监视器可能就是您的答案。请参阅以下 StackOverflow 问题以了解更多信息。
如何分析文件 I/O?
在此基础上构建回答,您可以在解决方案中搜索使用 Process Monitor 找到的任何常用读取或写入文件的文件名。
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.
stackshot方法,也称为随机暂停,会找到它,如果需要大量时间。
The stackshot method, also called random pausing, will find it, if it takes significant time.
如果 I/O 代码是托管的,您可以加载 .net 框架的符号并在关键函数(例如
FileStream
构造函数等)中设置断点。它涉及一些猜测工作,但如果您成功。
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.
除了进程监视器之外,我发现 Win7 上的资源监视器(我认为在 Vista 上也可以在“性能和可靠性”下找到)对于诊断与 I/O 相关的速度下降非常有用。切换到磁盘视图并按读/写或总计排序(仅限 win7)。另请注意出现的文件列表。
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.