The road to zen winds through self-monitoring applications, which can reduce the time and effort in diagnosing and correcting production issues. In this talk, we will see how modern Windows applications can self-monitor, self-diagnose, and potentially self-recover without needing an external monitoring agent or a brute-force restarting watchdog. By harnessing the power of ETW for low-level accurate monitoring, Windows performance counters for zero-overhead statistics, and the CLRMD library for inspecting your own threads, heap objects, and locks, you can take your applications one step closer to self-awareness. This will be illustrated through a series of demos: automatic CPU profiling and pinpointing the busy threads and stacks; automatic GC monitoring, including object allocations; automatic heap analysis to reveal unraveling memory leaks; and more. At the end of the talk, you will be equipped with tools and techniques for implementing self-monitoring in your own applications.
11. • Use a hierarchical monitoring strategy
• Lightweight for continuous and frequent monitoring
of all basics
Performance counters
12. • Use a hierarchical monitoring strategy
• Lightweight for continuous and frequent monitoring
of all basics
Performance counters
• Medium for less frequency events
ETW ClrMD
13. • Use a hierarchical monitoring strategy
• Lightweight for continuous and frequent monitoring
of all basics
Performance counters
• Medium for less frequency events
ETW ClrMD
• Invasive for deep-dive and concrete diagnostics
CLR Profiling API CLR Debugging API
15. • Monitor CPU using performance counters
• Are we above a certain threshold for a certain
amount of time?
LiveStacks
16. • AuthenticationController takes 95% CPU,
maybe we're being DDoS'ed
• Image processing component takes 100% CPU, need
to auto-scale the app
• Encoding this 30 second video takes 3 minutes at
100% CPU, tell the user she can send us a bug report
25. • Many more scenarios are possible
• Monitor heap fragmentation and compact large
objects if needed
26. • Many more scenarios are possible
• Monitor heap fragmentation and compact large
objects if needed
• Native memory leak analysis using ETW
27. • The pros are obvious (visibility, easy scaling…)
28. • The pros are obvious (visibility, easy scaling…)
• But there are some cons as well…
29. • The pros are obvious (visibility, easy scaling…)
• But there are some cons as well…
30. • The pros are obvious (visibility, easy scaling…)
• But there are some cons as well…
31. • The pros are obvious (visibility, easy scaling…)
• But there are some cons as well…
32. • Self-monitoring is important for all kinds of software
• Best to create a hierarchy of monitoring (and
overhead and complexity)
• Lots of scenarios: CPU, GC, memory, deadlocks
• Demos: https://github.com/dinazil/self-aware-
applications