SlideShare a Scribd company logo
Yevhen Tatarynov
Software developer with 15 years of experience in commercial
software and database development (.NET / MS SQL / Delphi)
PhD in math, specializing in the theoretical foundations of
computer science and cybernetics
I was involved in projects performing complex mathematical calculations and processing large
amounts of data. For now my role senior software developer in infrastructure team, Covent IT.
Point of professional interest:
application performance optimization and analysis
writing C# code similar in performance to C++
advanced debugging
Agenda
The first
challenge?
Measurements To much … ?
Summary
QA
The second
challenge?
Is It an
bottleneck?
Measurements
The first challenge?
Console .NET application
Read *.csv data files
Process data in
multiple threads
Write results in MS
Excel file
Use .NET Framework
4.6.2 Run on Windows It works correctly
Measurements
Measurement Tools
DotNetBenchmark
Visual Studio
Performance Profiler
Perfview R# dotTrace R# dotMemory
Performance
monitor
dotMemoryScreen
dotMemory Snapshot
dotTrace Snapshot
Too much…?
# Too many code issues?
Unused variables
Unused properties
Unused objects not allocated
Unused data not loaded from files
Unused fields don’t increase object
size
# Memory snapshot
Total memory old
Total memory new
Total memory diff
Percent
419,750 MB
359,971 MB
14 %
-55,599 MB
# Too many keys
ConcurrentDictionary<MyKey,string>
public struct MyKey
{
string field1;
string field2;
/*.....*/
}
Boxing
ConcurrentDictionary<TKey,TValue> classes have the same
functionality as the Hashtable class. A ConcurrentDictionary
<TKey,TValue> of a specific type (other than Object) provides
better performance than a Hashtable for value types.
This is because the elements of Hashtable are of type Object;
therefore, boxing and unboxing typically occur when you store
or retrieve a value type.
StackOverflow
Since you only override Equals and don’t implement
IEquatable<T>, the dictionary is forced to box one of the two
instances whenever it compares two of them for equality
because it's passing an instance into an
Equals-method-accepting object.
If you implement IEquatable<T>, then the dictionary can (and
will) use the version of Equals that accepts the parameter as a
T, which won't require boxing.
IEquatable interface
public struct MyKey : IEquatable<MyKey>
{
string field1;
string field2;
string field3;
/*.....*/
public bool Equals(MyKey other);
}
# Memory snapshot
Total memory old
Total memory new
Total memory diff
Percent
359,971 MB
137,294 MB
65 %
-251,654 MB
# Too much System.Double in heap?
class MyClass<T> where T : struct
{
T Add(T a, T b) =>
(dynamic)a+(dynamic)b;
}
We use only double type for T
class MyClass
{
double Add(double a, double b)
=> a + b;
}
For Struct we have no defined operation
+, so to maintain generic MyClass<T> we
need to cast to dynamic and we make
boxing ☹
We use only double type for T
# Memory snapshot
Total memory old
Total memory new
Total memory diff
Percent
140,550 MB
130,288 MB
7 %
-10,262 MB
# Still too much char[ ]?
/*
Collect single element of csv
string
*/
item=new List<char>();
/*.....*/
return item.ToArray();
# REUSE StringBuilder
char[] item
_stringBuilder.Clear();
/*.....*/
_stringBuilder.Write(item);
return item;
Cache StringBuilder in private field
No new Allocation
Can be used for different item
lengths
Can grow in 8,000 bytes if it’s
necessary to expand the internal buffer
# Memory snapshot
Total memory old
Total memory new
Total memory diff
Percent
59,565 MB
43,338 MB
27 %
-16,227 MB
# TOO MUCH <>c_DisplayClass26_0?
void AddValue(string key,string val)
/* Redundant lambda all data read
only */
dict.TryAdd(key,()=>new Data(val));
/*.....*/
# Memory snapshot
Total memory old
Total memory new
Total memory diff
Percent
34,243 MB
33,118 MB
3 %
-1,125 MB
The Second Challenge
WinForms .NET Applications
Read *.bin, *.txt data
files
“Process bits”, extract
and use full data, pack
into new format
It works correctly
Write results in text
and binary files
Use .NET
Framework 4.0
Run on Windows 10 x64
Measurements
dotMemory Snapshot
dotTrace TimeLine Sample & Snapshot Execution Time
Is It an bottleneck?
# Is Linq an bottleneck?
Potential Improvements
Used .ToArray() - slow
Concat use foreach and extra
memory to iterate input params
Each time we produce new byte array.
Redundant memory traffic.
var b = new byte[];
for (int i = 0; i < N; i++)
{
byte[] a = new byte[GetLen(i)];
/* fill a with values */
b = b.Concat(a).ToArray();
}
return b;
Buffer.BlockCopy
public static void BlockCopy
(Array src, int srcOffset, Array
dst, int dstOffset,
int count);
Copies a specified number of bytes from a
source array starting at a particular offset to a
destination array starting at a particular offset.
● src – Array The source buffer.
● srcOffset - Int32 The
zero-based byte offset into src.
● dst – Array The destination
buffer.
● dstOffset - Int32 The
zero-based byte offset into
dst.
● count - Int32 The number of
bytes to copy.
Comparison
var b = new byte[];
for (int i = 0; i < N; i++)
{
byte[] a = new byte[GetLen(i)];
/* fill a with values */
b = b.Concat(a).ToArray();
}
return b;
var b = new byte[maxN]; var bN=0;
for (int i = 0; i < N; i++)
{
var aN = GetLen(i);
byte[] a = new byte[aN];
/* fill a with values */
Buffer.BlockCopy(aN,0,b,bN,aN);
bN += aN;
}
return b;
#1 Performance Summary
Execution time
1st 374,011
120,333
68,83 %
-38 m 25 s 228 ms
Memory (MB)
2nd
Diff
%
43 m 21 s 642 ms
4 m 56 s 414 ms
-253,678
88,61 %
х 3,11
х 9,25
# Is FileStream.get_Length an bottleneck?
In both cases, the binary file read and
the basis on read data is the
calculated number of binary chains.
Potential Improvements
using(var br = new BinaryReader(…))
{
while (br.BaseStream.Position <= br.BaseStream.Length - 4)
{
counter++;
br.ReadUInt32();
br.ReadUInt32();
var n = br.ReadUInt32();
for (int i = 0; i < n; i++) br.ReadUInt32();
}
}
Redundant Length calls
Redundant subtraction
Redundant call
ReadUInt32
Solution
using(var br = new BinaryReader(…))
{
var length = br.BaseStream.Length - 4;
while (br.BaseStream.Position <= length)
{
counter++;
br.ReadUInt64();
var n = br.ReadUInt32();
for (int i = 0; i < n; i++) br.ReadUInt32();
}
}
Store Length in local
variable
Call ReadUInt64 instead
ReadUInt32
Comparison
using(var br = new BinaryReader(…))
{
while (br.BaseStream.Position <= br.BaseStream.Length - 4)
{
counter++;
br.ReadUInt32();
br.ReadUInt32();
var n = br.ReadUInt32();
for (int i = 0; i < n; i++) br.ReadUInt32();
}
}
using(var br = new BinaryReader(…))
{
var length = br.BaseStream.Length - 4;
while (br.BaseStream.Position <= length)
{
counter++;
br.ReadUInt64();
var n = br.ReadUInt32();
for (int i = 0; i < n; i++) br.ReadUInt32();
}
}
# Performance Summary
Execution time
Old 103,775
103,775
0.00 %
-31 s 786 ms
Memory (MB)
New
Diff
%
2 m 11 s 091 ms
1 m 39 s 305 ms
0
24.25 %
х 1.00
х 1.32
# ScaleGrad. - Can It Be Faster?
/*
Return index of number x by ordered
scale
*/
int ScaleGrad(int x)
Potential Improvements
static double[] Scale;
…
/* 600+ lines of code */
…
int ScaleGrad(int x)
{
for(int i=0; i<Scale.Length && Scale[i]<=x; i++)
return i - 1;
}
Avoid compare int and
double values
Scale is a sorted array, so
we can use binary search;
it’s more efficient and less
dependent on input data
Comparison
static double[] Scale;
/* 600+ lins of code */
int ScaleGrad(int x)
{
for(int i=0;(i<Scale.Length)&&(Scale[i]<= x);i++);
return i - 1;
}
static int[] Scale;
/* 600+ lins of code */
int ScaleGrad(int x)
var left = 1; var right = Scale.Length -1;
var mid =(left + right)>>1;//(left+right)/2
do {
mid = left + ((right - left)>>1);
if ( x < Scale[mid]) right = mid - 1;
else left = mid + 1;
} while (right >= left);
return mid;
#9 Performance Summary
Execution time
Old 9,754
9,754
0.00 %
-3 s 707 ms
Memory (MB)
New
Diff
%
32 s 551 ms
28 s 844 ms
0
11.39 %
х 1.00
х 1.13
Summary
PLEASE JOIN OUR WORKSHOP
TO SEE ALL OPTIMIZATION STEPS
Thank you!
Q&A
LINKS
Use dotTrace Command-Line Profiler Hashtable and dictionary collection types
.NET Performance Optimization &
Profiling with JetBrains dotTrace
Why GC run when using a struct as a
generic dictionary
Matt Ellis. Writing Allocation Free Code
in C#
Maarten Balliauw. Let’s refresh our
memory! Memory management in .NET
Sasha Goldshtein. Pro .NET Performance:
Optimize Your C# Applications
Ben Watson. Writing High-Performance
.NET Code, 2nd Edition
Maarten Balliauw
LINKS
Sasha Goldshtein
Yevhen Tatarynov GitHub
Writing Faster Managed Code: Know
What Things Cost
Ling.Concat
Linq.Concat Implementation
Buffer.BlockCopy
Generic List implementation
Konrad Kokosa. High-performance code
design patterns in C#

More Related Content

Similar to "Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov

CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
SukhpreetSingh519414
 
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
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
WatchDog13
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
AnkurSingh656748
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
tdc-globalcode
 
Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)
Dina Goldshtein
 
Oops presentation
Oops presentationOops presentation
Oops presentation
sushamaGavarskar1
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Languagemspline
 
Arrry structure Stacks in data structure
Arrry structure Stacks  in data structureArrry structure Stacks  in data structure
Arrry structure Stacks in data structure
lodhran-hayat
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its authorKaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Vivian S. Zhang
 
CUDA by Example : Parallel Programming in CUDA C : Notes
CUDA by Example : Parallel Programming in CUDA C : NotesCUDA by Example : Parallel Programming in CUDA C : Notes
CUDA by Example : Parallel Programming in CUDA C : Notes
Subhajit Sahu
 
Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languages
Ankit Pandey
 
Golang in TiDB (GopherChina 2017)
Golang in TiDB  (GopherChina 2017)Golang in TiDB  (GopherChina 2017)
Golang in TiDB (GopherChina 2017)
PingCAP
 
Implementation of Computational Algorithms using Parallel Programming
Implementation of Computational Algorithms using Parallel ProgrammingImplementation of Computational Algorithms using Parallel Programming
Implementation of Computational Algorithms using Parallel Programming
ijtsrd
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
SWETHAABIRAMIM
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
DrBashirMSaad
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
PVS-Studio
 

Similar to "Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov (20)

CPP-overviews notes variable data types notes
CPP-overviews notes variable data types notesCPP-overviews notes variable data types notes
CPP-overviews notes variable data types notes
 
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"
 
cppt-170218053903 (1).pptx
cppt-170218053903 (1).pptxcppt-170218053903 (1).pptx
cppt-170218053903 (1).pptx
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
 
Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
C++11: Feel the New Language
C++11: Feel the New LanguageC++11: Feel the New Language
C++11: Feel the New Language
 
Arrry structure Stacks in data structure
Arrry structure Stacks  in data structureArrry structure Stacks  in data structure
Arrry structure Stacks in data structure
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its authorKaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
 
CUDA by Example : Parallel Programming in CUDA C : Notes
CUDA by Example : Parallel Programming in CUDA C : NotesCUDA by Example : Parallel Programming in CUDA C : Notes
CUDA by Example : Parallel Programming in CUDA C : Notes
 
C sharp chap6
C sharp chap6C sharp chap6
C sharp chap6
 
Optimization in Programming languages
Optimization in Programming languagesOptimization in Programming languages
Optimization in Programming languages
 
Golang in TiDB (GopherChina 2017)
Golang in TiDB  (GopherChina 2017)Golang in TiDB  (GopherChina 2017)
Golang in TiDB (GopherChina 2017)
 
Implementation of Computational Algorithms using Parallel Programming
Implementation of Computational Algorithms using Parallel ProgrammingImplementation of Computational Algorithms using Parallel Programming
Implementation of Computational Algorithms using Parallel Programming
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
 
01_intro-cpp.ppt
01_intro-cpp.ppt01_intro-cpp.ppt
01_intro-cpp.ppt
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
cluster(python)
cluster(python)cluster(python)
cluster(python)
 

More from Fwdays

"What I learned through reverse engineering", Yuri Artiukh
"What I learned through reverse engineering", Yuri Artiukh"What I learned through reverse engineering", Yuri Artiukh
"What I learned through reverse engineering", Yuri Artiukh
Fwdays
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
"Micro frontends: Unbelievably true life story", Dmytro Pavlov
"Micro frontends: Unbelievably true life story", Dmytro Pavlov"Micro frontends: Unbelievably true life story", Dmytro Pavlov
"Micro frontends: Unbelievably true life story", Dmytro Pavlov
Fwdays
 
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
Fwdays
 
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
Fwdays
 
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
Fwdays
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
Fwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Fwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
Fwdays
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets
Fwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Fwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Fwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Fwdays
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
Fwdays
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
Fwdays
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
Fwdays
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
Fwdays
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
Fwdays
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
Fwdays
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
Fwdays
 

More from Fwdays (20)

"What I learned through reverse engineering", Yuri Artiukh
"What I learned through reverse engineering", Yuri Artiukh"What I learned through reverse engineering", Yuri Artiukh
"What I learned through reverse engineering", Yuri Artiukh
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
"Micro frontends: Unbelievably true life story", Dmytro Pavlov
"Micro frontends: Unbelievably true life story", Dmytro Pavlov"Micro frontends: Unbelievably true life story", Dmytro Pavlov
"Micro frontends: Unbelievably true life story", Dmytro Pavlov
 
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
"Objects validation and comparison using runtime types (io-ts)", Oleksandr Suhak
 
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
"JavaScript. Standard evolution, when nobody cares", Roman Savitskyi
 
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov

  • 1.
  • 2. Yevhen Tatarynov Software developer with 15 years of experience in commercial software and database development (.NET / MS SQL / Delphi) PhD in math, specializing in the theoretical foundations of computer science and cybernetics I was involved in projects performing complex mathematical calculations and processing large amounts of data. For now my role senior software developer in infrastructure team, Covent IT. Point of professional interest: application performance optimization and analysis writing C# code similar in performance to C++ advanced debugging
  • 3. Agenda The first challenge? Measurements To much … ? Summary QA The second challenge? Is It an bottleneck? Measurements
  • 5. Console .NET application Read *.csv data files Process data in multiple threads Write results in MS Excel file Use .NET Framework 4.6.2 Run on Windows It works correctly
  • 7. Measurement Tools DotNetBenchmark Visual Studio Performance Profiler Perfview R# dotTrace R# dotMemory Performance monitor
  • 12. # Too many code issues? Unused variables Unused properties Unused objects not allocated Unused data not loaded from files Unused fields don’t increase object size
  • 13. # Memory snapshot Total memory old Total memory new Total memory diff Percent 419,750 MB 359,971 MB 14 % -55,599 MB
  • 14. # Too many keys ConcurrentDictionary<MyKey,string> public struct MyKey { string field1; string field2; /*.....*/ }
  • 15. Boxing ConcurrentDictionary<TKey,TValue> classes have the same functionality as the Hashtable class. A ConcurrentDictionary <TKey,TValue> of a specific type (other than Object) provides better performance than a Hashtable for value types. This is because the elements of Hashtable are of type Object; therefore, boxing and unboxing typically occur when you store or retrieve a value type.
  • 16. StackOverflow Since you only override Equals and don’t implement IEquatable<T>, the dictionary is forced to box one of the two instances whenever it compares two of them for equality because it's passing an instance into an Equals-method-accepting object. If you implement IEquatable<T>, then the dictionary can (and will) use the version of Equals that accepts the parameter as a T, which won't require boxing.
  • 17. IEquatable interface public struct MyKey : IEquatable<MyKey> { string field1; string field2; string field3; /*.....*/ public bool Equals(MyKey other); }
  • 18. # Memory snapshot Total memory old Total memory new Total memory diff Percent 359,971 MB 137,294 MB 65 % -251,654 MB
  • 19. # Too much System.Double in heap? class MyClass<T> where T : struct { T Add(T a, T b) => (dynamic)a+(dynamic)b; }
  • 20. We use only double type for T class MyClass { double Add(double a, double b) => a + b; } For Struct we have no defined operation +, so to maintain generic MyClass<T> we need to cast to dynamic and we make boxing ☹ We use only double type for T
  • 21. # Memory snapshot Total memory old Total memory new Total memory diff Percent 140,550 MB 130,288 MB 7 % -10,262 MB
  • 22. # Still too much char[ ]? /* Collect single element of csv string */ item=new List<char>(); /*.....*/ return item.ToArray();
  • 23. # REUSE StringBuilder char[] item _stringBuilder.Clear(); /*.....*/ _stringBuilder.Write(item); return item; Cache StringBuilder in private field No new Allocation Can be used for different item lengths Can grow in 8,000 bytes if it’s necessary to expand the internal buffer
  • 24. # Memory snapshot Total memory old Total memory new Total memory diff Percent 59,565 MB 43,338 MB 27 % -16,227 MB
  • 25. # TOO MUCH <>c_DisplayClass26_0? void AddValue(string key,string val) /* Redundant lambda all data read only */ dict.TryAdd(key,()=>new Data(val)); /*.....*/
  • 26. # Memory snapshot Total memory old Total memory new Total memory diff Percent 34,243 MB 33,118 MB 3 % -1,125 MB
  • 28. WinForms .NET Applications Read *.bin, *.txt data files “Process bits”, extract and use full data, pack into new format It works correctly Write results in text and binary files Use .NET Framework 4.0 Run on Windows 10 x64
  • 31. dotTrace TimeLine Sample & Snapshot Execution Time
  • 32. Is It an bottleneck?
  • 33. # Is Linq an bottleneck?
  • 34. Potential Improvements Used .ToArray() - slow Concat use foreach and extra memory to iterate input params Each time we produce new byte array. Redundant memory traffic. var b = new byte[]; for (int i = 0; i < N; i++) { byte[] a = new byte[GetLen(i)]; /* fill a with values */ b = b.Concat(a).ToArray(); } return b;
  • 35. Buffer.BlockCopy public static void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count); Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset. ● src – Array The source buffer. ● srcOffset - Int32 The zero-based byte offset into src. ● dst – Array The destination buffer. ● dstOffset - Int32 The zero-based byte offset into dst. ● count - Int32 The number of bytes to copy.
  • 36. Comparison var b = new byte[]; for (int i = 0; i < N; i++) { byte[] a = new byte[GetLen(i)]; /* fill a with values */ b = b.Concat(a).ToArray(); } return b; var b = new byte[maxN]; var bN=0; for (int i = 0; i < N; i++) { var aN = GetLen(i); byte[] a = new byte[aN]; /* fill a with values */ Buffer.BlockCopy(aN,0,b,bN,aN); bN += aN; } return b;
  • 37. #1 Performance Summary Execution time 1st 374,011 120,333 68,83 % -38 m 25 s 228 ms Memory (MB) 2nd Diff % 43 m 21 s 642 ms 4 m 56 s 414 ms -253,678 88,61 % х 3,11 х 9,25
  • 38. # Is FileStream.get_Length an bottleneck? In both cases, the binary file read and the basis on read data is the calculated number of binary chains.
  • 39. Potential Improvements using(var br = new BinaryReader(…)) { while (br.BaseStream.Position <= br.BaseStream.Length - 4) { counter++; br.ReadUInt32(); br.ReadUInt32(); var n = br.ReadUInt32(); for (int i = 0; i < n; i++) br.ReadUInt32(); } } Redundant Length calls Redundant subtraction Redundant call ReadUInt32
  • 40. Solution using(var br = new BinaryReader(…)) { var length = br.BaseStream.Length - 4; while (br.BaseStream.Position <= length) { counter++; br.ReadUInt64(); var n = br.ReadUInt32(); for (int i = 0; i < n; i++) br.ReadUInt32(); } } Store Length in local variable Call ReadUInt64 instead ReadUInt32
  • 41. Comparison using(var br = new BinaryReader(…)) { while (br.BaseStream.Position <= br.BaseStream.Length - 4) { counter++; br.ReadUInt32(); br.ReadUInt32(); var n = br.ReadUInt32(); for (int i = 0; i < n; i++) br.ReadUInt32(); } } using(var br = new BinaryReader(…)) { var length = br.BaseStream.Length - 4; while (br.BaseStream.Position <= length) { counter++; br.ReadUInt64(); var n = br.ReadUInt32(); for (int i = 0; i < n; i++) br.ReadUInt32(); } }
  • 42. # Performance Summary Execution time Old 103,775 103,775 0.00 % -31 s 786 ms Memory (MB) New Diff % 2 m 11 s 091 ms 1 m 39 s 305 ms 0 24.25 % х 1.00 х 1.32
  • 43. # ScaleGrad. - Can It Be Faster? /* Return index of number x by ordered scale */ int ScaleGrad(int x)
  • 44. Potential Improvements static double[] Scale; … /* 600+ lines of code */ … int ScaleGrad(int x) { for(int i=0; i<Scale.Length && Scale[i]<=x; i++) return i - 1; } Avoid compare int and double values Scale is a sorted array, so we can use binary search; it’s more efficient and less dependent on input data
  • 45. Comparison static double[] Scale; /* 600+ lins of code */ int ScaleGrad(int x) { for(int i=0;(i<Scale.Length)&&(Scale[i]<= x);i++); return i - 1; } static int[] Scale; /* 600+ lins of code */ int ScaleGrad(int x) var left = 1; var right = Scale.Length -1; var mid =(left + right)>>1;//(left+right)/2 do { mid = left + ((right - left)>>1); if ( x < Scale[mid]) right = mid - 1; else left = mid + 1; } while (right >= left); return mid;
  • 46. #9 Performance Summary Execution time Old 9,754 9,754 0.00 % -3 s 707 ms Memory (MB) New Diff % 32 s 551 ms 28 s 844 ms 0 11.39 % х 1.00 х 1.13
  • 48. PLEASE JOIN OUR WORKSHOP TO SEE ALL OPTIMIZATION STEPS
  • 50. Q&A
  • 51. LINKS Use dotTrace Command-Line Profiler Hashtable and dictionary collection types .NET Performance Optimization & Profiling with JetBrains dotTrace Why GC run when using a struct as a generic dictionary Matt Ellis. Writing Allocation Free Code in C# Maarten Balliauw. Let’s refresh our memory! Memory management in .NET Sasha Goldshtein. Pro .NET Performance: Optimize Your C# Applications Ben Watson. Writing High-Performance .NET Code, 2nd Edition
  • 52. Maarten Balliauw LINKS Sasha Goldshtein Yevhen Tatarynov GitHub Writing Faster Managed Code: Know What Things Cost Ling.Concat Linq.Concat Implementation Buffer.BlockCopy Generic List implementation Konrad Kokosa. High-performance code design patterns in C#