SlideShare a Scribd company logo
1 of 70
Download to read offline
Mastering Macro
Benchmarking in
.NET
Konstantin
Yelisavenko
Lead .NET Developer
Work in Luxoft since 2016
kyelisavenko@luxoft.com
Micro vs Macro Benchmarking
Micro vs Macro Benchmarking
Micro
✘ Repeatable measurement of specific
sections of code
✘ Abstracted from virtual machine
warmup, garbage collections
and other side effects
Micro vs Macro Benchmarking
Micro
✘ Repeatable measurement of specific
sections of code
✘ Abstracted from virtual machine
warmup, garbage collections
and other side effects
Macro
✘ Repeatable measurement of whole
application or it’s part performance
from user point of view
✘ Abstracted from performance
overhead caused by monitoring
tools
Donald Knuth
“
Premature optimization
is the root of all evil
When we need optimization?
When we need optimization?
Obvious reasons :
When we need optimization?
Obvious reasons :
✘ Slow performance
When we need optimization?
Obvious reasons :
✘ Slow performance
✘ Memory consumption increasing
When we need optimization?
Obvious reasons :
✘ Slow performance
✘ Memory consumption increasing
Unobvious reasons :
When we need optimization?
Obvious reasons :
✘ Slow performance
✘ Memory consumption increasing
Unobvious reasons :
✘ GC.Collect()
private void memoryCheckTimer_Tick(object sender, EventArgs e)
{
var timer = sender as DispatcherTimer;
if (timer != null)
{
Process eProcess = Process.GetCurrentProcess();
GC.Collect();
eProcess.Refresh();
var ci = new Microsoft.VisualBasic.Devices.ComputerInfo();
ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024);
If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold")))
{
ShowWarningMessage("Low Memory Warning",
string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"),
Environment.NewLine));
timer.Stop();
timer.Tick -= memoryCheckTimer_Tick;
}
}
}
private void memoryCheckTimer_Tick(object sender, EventArgs e)
{
var timer = sender as DispatcherTimer;
if (timer != null)
{
Process eProcess = Process.GetCurrentProcess();
GC.Collect();
eProcess.Refresh();
var ci = new Microsoft.VisualBasic.Devices.ComputerInfo();
ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024);
If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold")))
{
ShowWarningMessage("Low Memory Warning",
string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"),
Environment.NewLine));
timer.Stop();
timer.Tick -= memoryCheckTimer_Tick;
}
}
}
private void memoryCheckTimer_Tick(object sender, EventArgs e)
{
var timer = sender as DispatcherTimer;
if (timer != null)
{
Process eProcess = Process.GetCurrentProcess();
GC.Collect();
eProcess.Refresh();
var ci = new Microsoft.VisualBasic.Devices.ComputerInfo();
ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024);
If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold")))
{
ShowWarningMessage("Low Memory Warning",
string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"),
Environment.NewLine));
timer.Stop();
timer.Tick -= memoryCheckTimer_Tick;
}
}
}
When we need optimization?
Obvious reasons :
✘ Slow performance
✘ Memory consumption increasing
Unobvious reasons :
✘ GC.Collect()
✘ Subscriptions management violated
When we need optimization?
Obvious reasons :
✘ Slow performance
✘ Memory consumption increasing
Unobvious reasons :
✘ GC.Collect()
✘ Subscriptions management violated
✘ UI freeze (“Not Responding”)
Vilfredo Pareto
According to Pareto Principle
According to Pareto Principle
20%of your codebase
According to Pareto Principle
20%of your codebase
do 80% of all job
20%
You should concentrate on those
What to consider before optimization?
What to consider before optimization?
Operation system
Windows, Linux, MacOS
What to consider before optimization?
Operation system
Windows, Linux, MacOS
Runtime type
CLR, Core CLR, Mono
What to consider before optimization?
Operation system
Windows, Linux, MacOS
Runtime type
CLR, Core CLR, Mono
Configuration
X86 or x64
What to consider before optimization?
Operation system
Windows, Linux, MacOS
Runtime type
CLR, Core CLR, Mono
Garbage collector type
GC, Boehm, Sgen
Configuration
X86 or x64
Also pay attention to…
Also pay attention to…
✘ How much time do you have for this task?
Also pay attention to…
✘ How much time do you have for this task?
✘ What target scenarios should be optimized?
Also pay attention to…
✘ How much time do you have for this task?
✘ What target scenarios should be optimized?
✘ How should you measure?
What to read before?
What to read before?
✘ “Writing High-Performance .NET Code” by Ben Watson
✘ “Under the Hood of .NET Memory Management” by Chris Farrell and
Nick Harrison
✘ “Detecting and Solving Memory Problems in .NET” by Alexey Totin
✘ Jetbrains official documentation
✘ Pluralsight course - “.NET Performance Optimization and Profiling
with JetBrains dotTrace” by Xavier Morera
Profiling stages
Profiling stages
collection visualization analysis
Snapshot strategies
Snapshot strategies
Performance
✘ Sampling (call time measurement using call stacks)
Snapshot strategies
Performance
✘ Sampling (call time measurement using call stacks)
✘ Tracing (number of calls using profiling API)
Snapshot strategies
Performance
✘ Sampling (call time measurement using call stacks)
✘ Tracing (number of calls using profiling API)
✘ Line-by-line (each statement execution time inside
function)
Snapshot strategies
Performance
✘ Sampling (call time measurement using call stacks)
✘ Tracing (number of calls using profiling API)
✘ Line-by-line (each statement execution time inside
function)
✘ Timeline (each thread activity visualization)
Snapshot strategies
Memory
✘ Image of managed heap created
Snapshot strategies
Memory
✘ Image of managed heap created
✘ Simulation of GC traversing through reference tree
What tools are available?
What tools are available?
Macro
✘ Visual Studio Profiling Tools
✘ “dotTrace” and “dotMemory”
from Jetbrains
✘ “ANTS Memory Profiler” from
Redgate
✘ “YourKit”
✘ Old good “Xperf” and
“PerfMon”
What tools are available?
Macro
✘ Visual Studio Profiling Tools
✘ “dotTrace” and “dotMemory”
from Jetbrains
✘ “ANTS Memory Profiler” from
Redgate
✘ “YourKit”
✘ Old good “Xperf” and
“PerfMon”
Micro
✘ “BenchmarkDotNet”
✘ ???
dotTrace features
dotTrace features
✘ Performance profiling with various levels of details
dotTrace features
✘ Performance profiling with various levels of details
✘ Hotspots and bottlenecks detection
dotTrace features
✘ Performance profiling with various levels of details
✘ Hotspots and bottlenecks detection
✘ Threads Timeline
dotTrace features
✘ Performance profiling with various levels of details
✘ Hotspots and bottlenecks detection
✘ Threads Timeline
✘ Performance gain forecasting
dotTrace features
✘ Performance profiling with various levels of details
✘ Hotspots and bottlenecks detection
✘ Threads Timeline
✘ Performance gain forecasting
✘ Remote profiling
dotTrace features
✘ Performance profiling with various levels of details
✘ Hotspots and bottlenecks detection
✘ Threads Timeline
✘ Performance gain forecasting
✘ Remote profiling
✘ Unit tests profiling
dotMemory features
dotMemory features
✘ Shows all allocated objects consumed be the app
dotMemory features
✘ Shows all allocated objects consumed be the app
✘ Shows current state of Finalization Queue
dotMemory features
✘ Shows all allocated objects consumed be the app
✘ Shows current state of Finalization Queue
✘ Shows how effectively collections are utilized
dotMemory features
✘ Shows all allocated objects consumed be the app
✘ Shows current state of Finalization Queue
✘ Shows how effectively collections are utilized
✘ Shows memory leaks
Out of profiling scope
✘ UI client side
✘ Database interactions
✘ Network and infrastructure communications
✘ Native Apps (iOS, Android)
Demo
Conclusion
Conclusion
✘ You can get answers to…
○ Why this s**t is working slowly?
○ Why this s**t is so hungry?
Conclusion
✘ You can get answers to…
○ Why this soft is working slowly?
○ Why this soft is so hungry?
Conclusion
✘ You can get answers to…
○ Why this soft is working slowly?
○ Why this soft is so hungry?
✘ More descriptive Technical debt items
Conclusion
✘ You can get answers to…
○ Why this soft is working slowly?
○ Why this soft is so hungry?
✘ More descriptive Technical debt items
✘ Ability to forecast performance gains
Conclusion
✘ You can get answers to…
○ Why this soft is working slowly?
○ Why this soft is so hungry?
✘ More descriptive Technical debt items
✘ Ability to forecast performance gains
✘ Can understand how dependent your project from 3-rd party
components
Conclusion
✘ You can get answers to…
○ Why this soft is working slowly?
○ Why this soft is so hungry?
✘ More descriptive Technical debt items
✘ Ability to forecast performance gains
✘ Can understand how dependent your project from 3-rd party
components
✘ Can create performance trend
thanks!
Any questions?

More Related Content

Similar to Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"

Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application MonitoringRavi Okade
 
Jun Heider - Flex Application Profiling By Example
Jun Heider - Flex Application Profiling By ExampleJun Heider - Flex Application Profiling By Example
Jun Heider - Flex Application Profiling By Example360|Conferences
 
Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools Matteo Valoriani
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Codemotion
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Codemotion
 
Zipline—Airbnb’s Declarative Feature Engineering Framework
Zipline—Airbnb’s Declarative Feature Engineering FrameworkZipline—Airbnb’s Declarative Feature Engineering Framework
Zipline—Airbnb’s Declarative Feature Engineering FrameworkDatabricks
 
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)Dina Goldshtein
 
Performance Oriented Design
Performance Oriented DesignPerformance Oriented Design
Performance Oriented DesignRodrigo Campos
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceESUG
 
WebSphere Technical University: Introduction to the Java Diagnostic Tools
WebSphere Technical University: Introduction to the Java Diagnostic ToolsWebSphere Technical University: Introduction to the Java Diagnostic Tools
WebSphere Technical University: Introduction to the Java Diagnostic ToolsChris Bailey
 
Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Giridhar Addepalli
 
Adtech x Scala x Performance tuning
Adtech x Scala x Performance tuningAdtech x Scala x Performance tuning
Adtech x Scala x Performance tuningYosuke Mizutani
 
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)Dina Goldshtein
 
DevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsDevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsTechWell
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScalePatrick Chanezon
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first designKyrylo Reznykov
 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Enginecatherinewall
 

Similar to Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET" (20)

Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application Monitoring
 
Jun Heider - Flex Application Profiling By Example
Jun Heider - Flex Application Profiling By ExampleJun Heider - Flex Application Profiling By Example
Jun Heider - Flex Application Profiling By Example
 
Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
 
Zipline—Airbnb’s Declarative Feature Engineering Framework
Zipline—Airbnb’s Declarative Feature Engineering FrameworkZipline—Airbnb’s Declarative Feature Engineering Framework
Zipline—Airbnb’s Declarative Feature Engineering Framework
 
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
 
Performance Oriented Design
Performance Oriented DesignPerformance Oriented Design
Performance Oriented Design
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
WebSphere Technical University: Introduction to the Java Diagnostic Tools
WebSphere Technical University: Introduction to the Java Diagnostic ToolsWebSphere Technical University: Introduction to the Java Diagnostic Tools
WebSphere Technical University: Introduction to the Java Diagnostic Tools
 
Jump start your application monitoring with APM
Jump start your application monitoring with APMJump start your application monitoring with APM
Jump start your application monitoring with APM
 
Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01
 
Adtech x Scala x Performance tuning
Adtech x Scala x Performance tuningAdtech x Scala x Performance tuning
Adtech x Scala x Performance tuning
 
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
DevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More DefectsDevOps: Find Solutions, Not More Defects
DevOps: Find Solutions, Not More Defects
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
 
Pc54
Pc54Pc54
Pc54
 
Raising ux bar with offline first design
Raising ux bar with offline first designRaising ux bar with offline first design
Raising ux bar with offline first design
 
Castles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App EngineCastles in the Cloud: Developing with Google App Engine
Castles in the Cloud: Developing with Google App Engine
 

More from LogeekNightUkraine

Autonomous driving on your developer pc. technologies, approaches, future
Autonomous driving on your developer pc. technologies, approaches, futureAutonomous driving on your developer pc. technologies, approaches, future
Autonomous driving on your developer pc. technologies, approaches, futureLogeekNightUkraine
 
Orkhan Gasimov "High Performance System Design"
Orkhan Gasimov "High Performance System Design" Orkhan Gasimov "High Performance System Design"
Orkhan Gasimov "High Performance System Design" LogeekNightUkraine
 
Vitalii Korzh "Managed Workflows or How to Master Data"
Vitalii Korzh "Managed Workflows or How to Master Data" Vitalii Korzh "Managed Workflows or How to Master Data"
Vitalii Korzh "Managed Workflows or How to Master Data" LogeekNightUkraine
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"LogeekNightUkraine
 
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"LogeekNightUkraine
 
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
Oleksandr Kutsan "Using katai struct to describe the process of working with ...Oleksandr Kutsan "Using katai struct to describe the process of working with ...
Oleksandr Kutsan "Using katai struct to describe the process of working with ...LogeekNightUkraine
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"LogeekNightUkraine
 
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"LogeekNightUkraine
 
Iurii Antykhovych "Java and performance tools and toys"
Iurii Antykhovych "Java and performance tools and toys"Iurii Antykhovych "Java and performance tools and toys"
Iurii Antykhovych "Java and performance tools and toys"LogeekNightUkraine
 
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...LogeekNightUkraine
 
Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"LogeekNightUkraine
 
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"LogeekNightUkraine
 
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
Alexandr Golyak, Nikolay Chertkov  "Automotive Testing vs Test Automatio"Alexandr Golyak, Nikolay Chertkov  "Automotive Testing vs Test Automatio"
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"LogeekNightUkraine
 
Michal Kordas "Docker: Good, Bad or Both"
Michal Kordas "Docker: Good, Bad or Both"Michal Kordas "Docker: Good, Bad or Both"
Michal Kordas "Docker: Good, Bad or Both"LogeekNightUkraine
 
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"LogeekNightUkraine
 
Shestakov Illia "The Sandbox Theory"
Shestakov Illia "The Sandbox Theory"Shestakov Illia "The Sandbox Theory"
Shestakov Illia "The Sandbox Theory"LogeekNightUkraine
 
Dmytro Kochergin “Autotest with CYPRESS”
Dmytro Kochergin “Autotest with CYPRESS”Dmytro Kochergin “Autotest with CYPRESS”
Dmytro Kochergin “Autotest with CYPRESS”LogeekNightUkraine
 
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”LogeekNightUkraine
 

More from LogeekNightUkraine (20)

Face recognition with c++
Face recognition with c++ Face recognition with c++
Face recognition with c++
 
C++20 features
C++20 features C++20 features
C++20 features
 
Autonomous driving on your developer pc. technologies, approaches, future
Autonomous driving on your developer pc. technologies, approaches, futureAutonomous driving on your developer pc. technologies, approaches, future
Autonomous driving on your developer pc. technologies, approaches, future
 
Orkhan Gasimov "High Performance System Design"
Orkhan Gasimov "High Performance System Design" Orkhan Gasimov "High Performance System Design"
Orkhan Gasimov "High Performance System Design"
 
Vitalii Korzh "Managed Workflows or How to Master Data"
Vitalii Korzh "Managed Workflows or How to Master Data" Vitalii Korzh "Managed Workflows or How to Master Data"
Vitalii Korzh "Managed Workflows or How to Master Data"
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"
 
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
 
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
Oleksandr Kutsan "Using katai struct to describe the process of working with ...Oleksandr Kutsan "Using katai struct to describe the process of working with ...
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
 
Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"Pavlo Zhdanov "Mastering solid and base principles for software design"
Pavlo Zhdanov "Mastering solid and base principles for software design"
 
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
 
Iurii Antykhovych "Java and performance tools and toys"
Iurii Antykhovych "Java and performance tools and toys"Iurii Antykhovych "Java and performance tools and toys"
Iurii Antykhovych "Java and performance tools and toys"
 
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
 
Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"Aleksandr Kutsan "Managing Dependencies in C++"
Aleksandr Kutsan "Managing Dependencies in C++"
 
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
 
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
Alexandr Golyak, Nikolay Chertkov  "Automotive Testing vs Test Automatio"Alexandr Golyak, Nikolay Chertkov  "Automotive Testing vs Test Automatio"
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
 
Michal Kordas "Docker: Good, Bad or Both"
Michal Kordas "Docker: Good, Bad or Both"Michal Kordas "Docker: Good, Bad or Both"
Michal Kordas "Docker: Good, Bad or Both"
 
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
 
Shestakov Illia "The Sandbox Theory"
Shestakov Illia "The Sandbox Theory"Shestakov Illia "The Sandbox Theory"
Shestakov Illia "The Sandbox Theory"
 
Dmytro Kochergin “Autotest with CYPRESS”
Dmytro Kochergin “Autotest with CYPRESS”Dmytro Kochergin “Autotest with CYPRESS”
Dmytro Kochergin “Autotest with CYPRESS”
 
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Kostiantyn Yelisavenko "Mastering Macro Benchmarking in .NET"

  • 2. Konstantin Yelisavenko Lead .NET Developer Work in Luxoft since 2016 kyelisavenko@luxoft.com
  • 3. Micro vs Macro Benchmarking
  • 4. Micro vs Macro Benchmarking Micro ✘ Repeatable measurement of specific sections of code ✘ Abstracted from virtual machine warmup, garbage collections and other side effects
  • 5. Micro vs Macro Benchmarking Micro ✘ Repeatable measurement of specific sections of code ✘ Abstracted from virtual machine warmup, garbage collections and other side effects Macro ✘ Repeatable measurement of whole application or it’s part performance from user point of view ✘ Abstracted from performance overhead caused by monitoring tools
  • 6.
  • 9. When we need optimization?
  • 10. When we need optimization? Obvious reasons :
  • 11. When we need optimization? Obvious reasons : ✘ Slow performance
  • 12. When we need optimization? Obvious reasons : ✘ Slow performance ✘ Memory consumption increasing
  • 13. When we need optimization? Obvious reasons : ✘ Slow performance ✘ Memory consumption increasing Unobvious reasons :
  • 14. When we need optimization? Obvious reasons : ✘ Slow performance ✘ Memory consumption increasing Unobvious reasons : ✘ GC.Collect()
  • 15. private void memoryCheckTimer_Tick(object sender, EventArgs e) { var timer = sender as DispatcherTimer; if (timer != null) { Process eProcess = Process.GetCurrentProcess(); GC.Collect(); eProcess.Refresh(); var ci = new Microsoft.VisualBasic.Devices.ComputerInfo(); ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024); If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold"))) { ShowWarningMessage("Low Memory Warning", string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"), Environment.NewLine)); timer.Stop(); timer.Tick -= memoryCheckTimer_Tick; } } }
  • 16. private void memoryCheckTimer_Tick(object sender, EventArgs e) { var timer = sender as DispatcherTimer; if (timer != null) { Process eProcess = Process.GetCurrentProcess(); GC.Collect(); eProcess.Refresh(); var ci = new Microsoft.VisualBasic.Devices.ComputerInfo(); ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024); If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold"))) { ShowWarningMessage("Low Memory Warning", string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"), Environment.NewLine)); timer.Stop(); timer.Tick -= memoryCheckTimer_Tick; } } }
  • 17. private void memoryCheckTimer_Tick(object sender, EventArgs e) { var timer = sender as DispatcherTimer; if (timer != null) { Process eProcess = Process.GetCurrentProcess(); GC.Collect(); eProcess.Refresh(); var ci = new Microsoft.VisualBasic.Devices.ComputerInfo(); ulong mem = ulong.Parse(CI.AvailablePhysicalMemory.ToString()) / (1024 * 1024); If (mem <= ulong.Parse(ConfigurationManager.AppSettings.Get("MemoryLowThreshold"))) { ShowWarningMessage("Low Memory Warning", string.Format(System.Configuration.ConfigurationManager.AppSettings.Get("MemoryLowMessage"), Environment.NewLine)); timer.Stop(); timer.Tick -= memoryCheckTimer_Tick; } } }
  • 18. When we need optimization? Obvious reasons : ✘ Slow performance ✘ Memory consumption increasing Unobvious reasons : ✘ GC.Collect() ✘ Subscriptions management violated
  • 19. When we need optimization? Obvious reasons : ✘ Slow performance ✘ Memory consumption increasing Unobvious reasons : ✘ GC.Collect() ✘ Subscriptions management violated ✘ UI freeze (“Not Responding”)
  • 20.
  • 22. According to Pareto Principle
  • 23. According to Pareto Principle 20%of your codebase
  • 24. According to Pareto Principle 20%of your codebase do 80% of all job
  • 26. What to consider before optimization?
  • 27. What to consider before optimization? Operation system Windows, Linux, MacOS
  • 28. What to consider before optimization? Operation system Windows, Linux, MacOS Runtime type CLR, Core CLR, Mono
  • 29. What to consider before optimization? Operation system Windows, Linux, MacOS Runtime type CLR, Core CLR, Mono Configuration X86 or x64
  • 30. What to consider before optimization? Operation system Windows, Linux, MacOS Runtime type CLR, Core CLR, Mono Garbage collector type GC, Boehm, Sgen Configuration X86 or x64
  • 32. Also pay attention to… ✘ How much time do you have for this task?
  • 33. Also pay attention to… ✘ How much time do you have for this task? ✘ What target scenarios should be optimized?
  • 34. Also pay attention to… ✘ How much time do you have for this task? ✘ What target scenarios should be optimized? ✘ How should you measure?
  • 35. What to read before?
  • 36. What to read before? ✘ “Writing High-Performance .NET Code” by Ben Watson ✘ “Under the Hood of .NET Memory Management” by Chris Farrell and Nick Harrison ✘ “Detecting and Solving Memory Problems in .NET” by Alexey Totin ✘ Jetbrains official documentation ✘ Pluralsight course - “.NET Performance Optimization and Profiling with JetBrains dotTrace” by Xavier Morera
  • 40. Snapshot strategies Performance ✘ Sampling (call time measurement using call stacks)
  • 41. Snapshot strategies Performance ✘ Sampling (call time measurement using call stacks) ✘ Tracing (number of calls using profiling API)
  • 42. Snapshot strategies Performance ✘ Sampling (call time measurement using call stacks) ✘ Tracing (number of calls using profiling API) ✘ Line-by-line (each statement execution time inside function)
  • 43. Snapshot strategies Performance ✘ Sampling (call time measurement using call stacks) ✘ Tracing (number of calls using profiling API) ✘ Line-by-line (each statement execution time inside function) ✘ Timeline (each thread activity visualization)
  • 44. Snapshot strategies Memory ✘ Image of managed heap created
  • 45. Snapshot strategies Memory ✘ Image of managed heap created ✘ Simulation of GC traversing through reference tree
  • 46. What tools are available?
  • 47. What tools are available? Macro ✘ Visual Studio Profiling Tools ✘ “dotTrace” and “dotMemory” from Jetbrains ✘ “ANTS Memory Profiler” from Redgate ✘ “YourKit” ✘ Old good “Xperf” and “PerfMon”
  • 48. What tools are available? Macro ✘ Visual Studio Profiling Tools ✘ “dotTrace” and “dotMemory” from Jetbrains ✘ “ANTS Memory Profiler” from Redgate ✘ “YourKit” ✘ Old good “Xperf” and “PerfMon” Micro ✘ “BenchmarkDotNet” ✘ ???
  • 50. dotTrace features ✘ Performance profiling with various levels of details
  • 51. dotTrace features ✘ Performance profiling with various levels of details ✘ Hotspots and bottlenecks detection
  • 52. dotTrace features ✘ Performance profiling with various levels of details ✘ Hotspots and bottlenecks detection ✘ Threads Timeline
  • 53. dotTrace features ✘ Performance profiling with various levels of details ✘ Hotspots and bottlenecks detection ✘ Threads Timeline ✘ Performance gain forecasting
  • 54. dotTrace features ✘ Performance profiling with various levels of details ✘ Hotspots and bottlenecks detection ✘ Threads Timeline ✘ Performance gain forecasting ✘ Remote profiling
  • 55. dotTrace features ✘ Performance profiling with various levels of details ✘ Hotspots and bottlenecks detection ✘ Threads Timeline ✘ Performance gain forecasting ✘ Remote profiling ✘ Unit tests profiling
  • 57. dotMemory features ✘ Shows all allocated objects consumed be the app
  • 58. dotMemory features ✘ Shows all allocated objects consumed be the app ✘ Shows current state of Finalization Queue
  • 59. dotMemory features ✘ Shows all allocated objects consumed be the app ✘ Shows current state of Finalization Queue ✘ Shows how effectively collections are utilized
  • 60. dotMemory features ✘ Shows all allocated objects consumed be the app ✘ Shows current state of Finalization Queue ✘ Shows how effectively collections are utilized ✘ Shows memory leaks
  • 61. Out of profiling scope ✘ UI client side ✘ Database interactions ✘ Network and infrastructure communications ✘ Native Apps (iOS, Android)
  • 62. Demo
  • 64. Conclusion ✘ You can get answers to… ○ Why this s**t is working slowly? ○ Why this s**t is so hungry?
  • 65. Conclusion ✘ You can get answers to… ○ Why this soft is working slowly? ○ Why this soft is so hungry?
  • 66. Conclusion ✘ You can get answers to… ○ Why this soft is working slowly? ○ Why this soft is so hungry? ✘ More descriptive Technical debt items
  • 67. Conclusion ✘ You can get answers to… ○ Why this soft is working slowly? ○ Why this soft is so hungry? ✘ More descriptive Technical debt items ✘ Ability to forecast performance gains
  • 68. Conclusion ✘ You can get answers to… ○ Why this soft is working slowly? ○ Why this soft is so hungry? ✘ More descriptive Technical debt items ✘ Ability to forecast performance gains ✘ Can understand how dependent your project from 3-rd party components
  • 69. Conclusion ✘ You can get answers to… ○ Why this soft is working slowly? ○ Why this soft is so hungry? ✘ More descriptive Technical debt items ✘ Ability to forecast performance gains ✘ Can understand how dependent your project from 3-rd party components ✘ Can create performance trend