Windows服务应用程序中的100%CPU使用率 [英] 100% CPU Usage in windows service application

查看:194
本文介绍了Windows服务应用程序中的100%CPU使用率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows服务应用程序中遇到了100%的CPU使用率问题。



我使用了Visual Studio 2012的性能分析器并得到了以下根本原因CPU占用率超过90%并显示为热门路径。



我们正在从共享路径读取文件并将其内容插入到DB中。使用线程机制。



我们正在使用大约20个正则表达式的Regexlist,并将它的每个正则表达式与文件的每个行文本相匹配,如果它匹配,我们发送的是作为电子邮件发送。



如果以下功能可以通过其它方式完成,请提供帮助,因为它显示为相同的最高CPU使用率。



请找到我们正在使用的以下内容.. * [eE] [rR] [rR] [oO] [rR]。*。* [eE] [xX] [cC ] [EE] [PP] [TT] [II] [OO] [NN] *。 。* Full Thread Dump。*。*可能GC。*。* left群集与高级会员。*。*加入群集与高级会员。*



请放手我知道是否有其他方法可以为我的Windows服务应用程序找到高CPU用量。



private bool ShouldInclude(LogLine logLine)

{

if(_includeRegexList.Count == 0)

返回true;



foreach (_includeRegexList中的正则表达式正则表达式)

{

if(regex.IsMatch(logLine.Text))

返回true;

}



返回false;

}

I am getting the 100% CPU Usage issue in my Windows service application.

I used the performance analyzer of Visual Studio 2012 and got the below root cause which is having more than 90% CPU usage and shown as a hot path.

We are reading file from shared path and inserting the content of it in DB. Using threading mechanism for it.

We are using Regexlist of around 20 regex and matching each regex of it with file's each line text and if it is matching we are sending that line as an email.

please help if below function can be done in some other way as it is showing as highest CPU usage for the same.

please find below reged which we are using.. .*[eE][rR][rR][oO][rR].* .*[eE][xX][cC][eE][pP][tT][iI][oO][nN]*. .*Full Thread Dump.* .*possible GC.* .*left Cluster with senior member.* .*joined Cluster with senior member.*

please do let me know if is there any other method by which I can find the high CPU USAGE for my windows service application.

private bool ShouldInclude(LogLine logLine)
{
if (_includeRegexList.Count == 0)
return true;

foreach (Regex regex in _includeRegexList)
{
if (regex.IsMatch(logLine.Text))
return true;
}

return false;
}

推荐答案

百分比用法不是有效的指标。 Id不仅取决于您的应用程序,还取决于其他应用程序的功能。如果所有其他进程都处于空闲状态,那么对于某些应用程序具有高CPU使用率更为合理,这些应用程序会永久地完成一些实际工作。



当然,大多数UI应用程序,当没有由用户主动操作,应该在所有线程中花费100%的时间处于等待状态,这根本不消耗CPU时间。另一方面,如果您的服务是在客户端 - 服务器模型上运行的,那么当没有来自客户端的请求时,它也应该花费零CPU时间。但是,如果这项服务永久地做了一些活跃的工作,比如根据给它的一些任务来处理一些数字,那么高CPU使用率就越好,越多越好。



根据您的有限信息,很难添加任何其他内容,但我希望这些基本想法可以帮助您了解如何分析您的问题。首先,到目前为止,我没有看到你真正遇到任何问题的证据。



-SA
Percentage of the usage is not a valid metrics. Id does not depends solely on your application, it depends on what other applications do. If all other processes are idle, it's more then reasonable to have high CPU usage for some application which permanently does some real work.

Naturally, most UI applications, when not actively operated by the users, should spend 100% of time in a wait state in all the threads, which does not consume CPU time at all. From the other hand, if your service is operated on the client-server model, it should also spend zero CPU time when there are no requests from the clients. But if this service permanently does some active work, say, crunching some numbers according to some task given to it, high CPU usage would be desirable, the more the better.

Based on your limited information, it's hard to add anything else, but I hope these basic ideas can help you to understand how to analyze your problem. First of all, so far, I see no evidence that you really face any problem.

—SA

这篇关于Windows服务应用程序中的100%CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆