性能计数器与 ETW
性能计数器是 ETW 的一部分吗?如果不是,两者有什么区别?
Are performance counters part of ETW? If not, what is the difference between the two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
性能计数器是 ETW 的一部分吗?如果不是,两者有什么区别?
Are performance counters part of ETW? If not, what is the difference between the two?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
性能计数器和 ETW 是不同的技术。性能计数器不通过 ETW 公开。
基本区别:性能计数器提供有关系统行为的高级指标(想想计时器和读取的字节以及分配的对象),而 ETW 是一个诊断跟踪和日志记录工具(想想 Debug.WriteLine 消息,但更丰富和更丰富)更加结构化)。
目前,ETW 和性能计数器都得到了 Windows 的全面支持,作为开发人员,您可以编写代码来生成和使用这两种技术的数据。
性能计数器
性能计数器< /a> 也称为 PDH(性能数据助手)计数器,是简单的数字指标,可以为您提供特定系统行为方式的高级摘要。例如,
% Processor Time
是一个性能计数器,它告诉您有多少处理器时间用于执行用户模式代码。作为一个更复杂的示例,.NET CLR Jit
类别中的# ofMethods Jitted
告诉您自应用程序启动以来有多少个 .NET 方法被 JIT 编译。性能计数器通常用于监视系统运行状况并诊断特定的性能问题。当出现严重错误时,它们可以很好地指示问题,但它们不会为您提供有关特定问题发生原因的详细信息。
要查看 Windows 性能计数器,您只需运行
perfmon
即可。在 Vista+ 上,您可能需要单击“性能监视器”节点才能查看计数器图表。要以编程方式访问性能计数器,请查看System.Diagnostics .NET 中的 .PerformanceCounter
类或 PDH 库。Windows 事件跟踪 (ETW)
ETW 是 Windows 内置的跟踪系统。本质上,任何组件(例如用户应用程序,甚至Windows 内核本身)都可以发送有关该组件所关心的特定事件的诊断跟踪信息。例如,当进程启动和停止时、加载和卸载映像(例如 DLL)时、创建或销毁线程时、甚至线程进行上下文切换时,内核都会发出 ETW 事件。记录的数据采用由组件在其他地方描述的序列化格式,允许诊断工具读取和理解会话期间记录的 ETW 事件。有关盒线图,请参阅此处一切如何协同工作。
ETW 旨在快速,并且在未启用日志记录时不应对系统性能产生重大影响。从 Vista 开始,ETW 在整个 Windows 中普遍存在,旨在供应用程序开发人员使用(具体来说,您的应用程序可以是记录事件的 ETW 提供程序)。 ETW 是事件日志的基础,可供性能分析器、调试器或系统监视器使用。
请参阅我的另一篇文章此处了解有关与 ETW 接口。
Performance counters and ETW are distinct technologies. Performance counters are not exposed through ETW.
The basic difference: performance counters provide high-level metrics on system behavior (think timers and bytes read and objects allocated) while ETW is a diagnostic tracing and logging facility (think
Debug.WriteLine
messages, but richer and more structured).Currently, both ETW and performance counters have full support from Windows, and as a developer, you can write code to produce and consume data for both technologies.
Performance Counters
Performance counters, also known as PDH (Performance Data Helper) counters, are simple numeric metrics that give you a high-level summary of how a particular system is behaving. For example,
% Processor Time
is a performance counter that tells you how much of the processor's time is being used to execute user-mode code. As a more complex example,# of Methods Jitted
in the.NET CLR Jit
category tells you how many .NET methods were JIT compiled since the start of an application.Performance counters are generally used to monitor system health and to diagnose specific performance issues. They are a good indicator of issues when something goes wildly wrong, but they don't give you much detail as to why a particular issue is happening.
To view Windows performance counters, you can simply run
perfmon
. On Vista+, you might need to click on the "Performance Monitor" node to see the counter chart. To programmatically access performance counters, look at theSystem.Diagnostics.PerformanceCounter
class in .NET or the PDH library for native code.Event Tracing for Windows (ETW)
ETW is a tracing system built into Windows. Essentially, any component (e.g. a user application, or even the Windows kernel itself) can send out diagnostic trace information about specific events that occur that the component cares about. For example, the kernel sends out ETW events when a process starts and stops, when an image (e.g. DLL) is loaded and unloaded, when a thread is created or destroyed, or even when a thread does a context switch. The logged data is in a serialized format that's described by the component elsewhere, allowing diagnostic tools to read and understand the ETW events logged during a session. See here for a boxes-and-lines diagram of how everything works together.
ETW is meant to be fast and should not materially impact the system's performance when logging is not enabled. Starting with Vista, ETW is pervasive throughout Windows and is intended for use by application developers (meaning, specifically, your application can be an ETW provider that logs events). ETW is the basis for the Event Log, and can be used by performance profilers, debuggers, or system monitors.
See my other SO post here for some resources on interfacing with ETW.
似乎基于 此文档 从 Vista+ 开始性能计数器具有 ETW Façade,因此可以按照与 ETW 完全相同的方式使用它们。
Windows Vista® 中包含的新性能计数器库(PERFLIB 版本 2.0)为开发人员提供了许多优势,包括:
提供者和使用者之间基于 Windows 事件跟踪的标准进程间通信 (IPC) 机制( ETW) 通知,从而简化开发并提高代码的统一性和可靠性。
It would seem that based on this document starting in Vista+ performance counters have an ETW Façade so they can be consumed exactly in the same way as ETW.
The new Performance Counter Library (PERFLIB version 2.0) included with Windows Vista® offers a number of advantages to the developer, including:
A standard inter-process communication (IPC) mechanism between a provider and consumer that is based on Event Tracing for Windows (ETW) notification, and which results in simplified development and more uniform and reliable code.