Please enable JavaScript.
Coggle requires JavaScript to display documents.
Measuring .Net Performance (4. Measuring memory (Tools (concurrence…
Measuring .Net Performance
1. Identifying performance metrics
CPU
Memory
GUI
Network
Continous performance Monitoring
[Production]
Performance regrestion testing
Automatic tests
3. UI responsiving
VS extention
Concurrency visualizer
VS Timeline tool
XAML
2. Measuring CPU-bound application performance
Examples
Video Rendering
Image processing
"Complex" Linq queries
types
Sampling (Perfilador de muestreo)
Takes periodically stack samples
Low overhead
Non CPU work is completely invisible
Instrumentation (Perfilador de instrumentacion)
Injects code in every method entry and exit
Take 1000 samples every second by default
You can attach to interest code to reduce the overhead (50% can be increased cause profiler)
Visual studio
Analyze -> Performance profiler
sampling
Also you can attach to one process
When not is open project, you can click in "show all code" to view complete report
jetBrains dottrace
Instrumentation
Detect Thread.wait method
PerfView :!:
Free
Capture all process system
Uncheck zp and merge options when is local pc
Low level cpu effects
(cache - intensive memory access)
intel : Intel VTune amplifier
amd: Codigo analyst
4. Measuring memory
Tools
concurrence visualizer: threads time, GC thread
perf view: types and calls to allocate
vmmap: memory fragmentation
Overview
GC garbage collector effects
GC interaction with other threads application
In production environments the delay can be in seconds, not miliseconds
Page faults also add delays
+= concat replace for StringWriter wich internallly use a stringBuilder. improves execution time and presure GC
Improve
reduce allocations
avoid assign big objects when they have short life cicle
Memory fragmentation
GC trhows a memory exception if requires 64 mb but is avaliable in two fragments (40 mb and 40 mb)
X64 is a big solution with many memory adrresses
In 32 bits operative system in 4gb ram assing only 2gb to 32bits application
6. Measuring data layer performance
ORM
Select N +1 trouble, to retrieve the reference objects
Overly complex queries
Poor database configuration (first level: session; second level: any session)
Don't use bulk operations
Tools
Entity Framework profiler
Show alerts (red point)
Show queries
Show query's tables
5. Getting Rid of Memory Leaks
The GC manages memory automatically but leaks can happen
Multiple GC roots refer to particular object
Locating memory leaks
Dominator Trees
Short dominator path
Optimizing heap snapShots
Take 10% of objects with dominators roots
Tools
DotMemory (JetBrains)
String, array is common survived objects
Group by similar Retention
Group by domintators (Tree)
In the example register and unregister eventHandlers
Perf view
Production environments cause it is the only can take screenshot of large application with complex heaps [Example cache xml in visual studio]
Don't show tree dominators
Menu (Diff with base line)
https://nirajrules.wordpress.com/2009/09/17/measuring-performance-response-vs-latency-vs-throughput-vs-load-vs-scalability-vs-stress-vs-robustness/