SlideShare a Scribd company logo
1 of 90
Download to read offline
–
…
’
Latency
Throughput
/
Latency Mystery series
0
50 000 000
100 000 000
150 000 000
200 000 000
250 000 000
300 000 000
350 000 000
400 000 000
450 000 000
500 000 000
1 thread no lock 1 thread with lock
ops/s per thread
2ns
0
50 000
100 000
150 000
200 000
250 000
1 thread
no lock
1 thread
with lock
2 threads 3 threads 4 threads 5 threads
ops/s per thread global ops/s
5µs
0
2 000 000
4 000 000
6 000 000
8 000 000
10 000 000
12 000 000
1 thread 2 threads 3 threads 4 threads 5 threads
99 99,5 99,99 99,999 max
5µs
”
“
Cache
Cache
CORE 0 Thread A
CPU
Memory
CORE 1 Thread B
Cache
Cache
CORE 0 Thread A
CPU
Memory
CORE 1
Cache
Cache
CORE 0
CPU
Memory
CORE 1 Thread B
Cache
Cache
CORE 0 Thread A
CPU
Memory
CORE 1 Thread B
Cache
Cache
CORE 0 Thread A
CPU
Memory
CORE 1 Thread B
Cache
Cache
CORE 0 Thread A
CPU
Memory
CORE 1 Thread B
’
’
“
List<int> list = new List<int>();
foreach (var i in list)
{
// Do something
}
IList<int> list = new List<int>();
foreach (var i in list)
{
// Do something
}
public Enumerator GetEnumerator()
{
// Enumerator is a struct
return new Enumerator(this);
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator(this); // boxing
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(this); // boxing
}
struct Cucumber: IDisposable
{
void Dispose()
{
}
}
Var c = new Cucumber();
c.Dispose();
IL_0000: ldloca.s c
IL_0002: initobj Cucumber
IL_0008: ldloca.s c
IL_000a: call instance void Cucumber::Dispose()
Idisposable c = new Cucumber();
c.Dispose();
IL_0000: ldloca.s CS$0$0000
IL_0002: initobj Cucumber
IL_0008: ldloc.1
IL_0009: box Cucumber
IL_000e: stloc.0
IL_000f: ldloc.0
IL_0010: callvirt instance void IDisposable::Dispose()
using(var c = new Cucumber())
{
}
IL_0000: ldloca.s c
IL_0002: initobj Cucumber
.try {
IL_0008: leave.s IL_0018
} finally {
IL_000a: ldloca.s c
IL_000c: constrained. Cucumber
IL_0012: callvirt instance void IDisposable::Dispose()
IL_0017: endfinally
}
void DoSomething(IDisposable arg)
void DoSomething<T>(T arg) where T : IDisposable
*
[StructLayout(LayoutKind.Sequential)]
private struct DecimalProxy
{
public readonly int flags;
public readonly int hi;
public readonly int lo;
public readonly int mid;
}
var d = 42m;
var decimalProxy =
*((DecimalProxy*)(&d));
var flags = decimalProxy.flags;
var lo = decimalProxy.lo;
var mid = decimalProxy.mid;
var hi = decimalProxy.hi;
// Enjoy your flags-lo-mid-high!
’
// using lambda
DoSomething(() => Console.WriteLine());
// delegate from method group
DoSomething(Console.WriteLine);
// capturing local variable
DoSomething(() => local++);
// capturing field
DoSomething(() => _field++);
public class NCrafts
{
private int _field;
private void DoSomething(Action action){}
public void Test()
{
DoSomething(() => _field++);
}
}
public class NCrafts
{
private int _field;
private void DoSomething(Action action){}
public void Test()
{
DoSomething(new Action(AnonymousMethod));
}
[CompilerGenerated]
public void AnonymousMethod()
{
_field++;
}
}
public class NCrafts
{
private static int _field;
private void DoSomething(Action action){}
public void Test()
{
DoSomething(() => _field++);
}
}
public class NCrafts
{
[CompilerGenerated]
private static Action _cachedDelegate;
private static int _field;
private static void DoSomething(Action action){}
public void Test()
{
if (_cachedDelegate == null)
_cachedDelegate = new Action(Anonymous);
DoSomething(_cachedDelegate);
}
[CompilerGenerated]
private static void Anonymous()
{
_field++;
}
}
}
finally
{
// low-latency
// can be a
// business
// requirement
// it’s hard no
// matter what
// stack you
// rely on
// low-latency
// in managed
// code is a
// real option
// is there a
// trend here?
talk.Close();
}
Low latency in managed code

More Related Content

Similar to Low latency in managed code

JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
Shellcoding in linux
Shellcoding in linuxShellcoding in linux
Shellcoding in linuxAjin Abraham
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Pluginsamiable_indian
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsAndrei Pangin
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаsamsolutionsby
 
The Ring programming language version 1.2 book - Part 80 of 84
The Ring programming language version 1.2 book - Part 80 of 84The Ring programming language version 1.2 book - Part 80 of 84
The Ring programming language version 1.2 book - Part 80 of 84Mahmoud Samir Fayed
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby SystemsEngine Yard
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLConnor McDonald
 
Владимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsВладимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsUA Mobile
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Playing CTFs for Fun & Profit
Playing CTFs for Fun & ProfitPlaying CTFs for Fun & Profit
Playing CTFs for Fun & Profitimpdefined
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelVitaly Nikolenko
 
Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6scuhurricane
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXLLinaro
 
The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180Mahmoud Samir Fayed
 

Similar to Low latency in managed code (20)

JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
The zen of async: Best practices for best performance
The zen of async: Best practices for best performanceThe zen of async: Best practices for best performance
The zen of async: Best practices for best performance
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Shellcoding in linux
Shellcoding in linuxShellcoding in linux
Shellcoding in linux
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap Dumps
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
Профилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кодаПрофилирование и оптимизация производительности Ruby-кода
Профилирование и оптимизация производительности Ruby-кода
 
The Ring programming language version 1.2 book - Part 80 of 84
The Ring programming language version 1.2 book - Part 80 of 84The Ring programming language version 1.2 book - Part 80 of 84
The Ring programming language version 1.2 book - Part 80 of 84
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
 
Владимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-ApplicationsВладимир Кириллов-TCP-Performance for-Mobile-Applications
Владимир Кириллов-TCP-Performance for-Mobile-Applications
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Playing CTFs for Fun & Profit
Playing CTFs for Fun & ProfitPlaying CTFs for Fun & Profit
Playing CTFs for Fun & Profit
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Ieee 1149.1-2013-tutorial-ijtag
Ieee 1149.1-2013-tutorial-ijtagIeee 1149.1-2013-tutorial-ijtag
Ieee 1149.1-2013-tutorial-ijtag
 
Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6Rootkit on linux_x86_v2.6
Rootkit on linux_x86_v2.6
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXL
 
The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180The Ring programming language version 1.5.1 book - Part 44 of 180
The Ring programming language version 1.5.1 book - Part 44 of 180
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

Low latency in managed code

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 20. /
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. 0 50 000 000 100 000 000 150 000 000 200 000 000 250 000 000 300 000 000 350 000 000 400 000 000 450 000 000 500 000 000 1 thread no lock 1 thread with lock ops/s per thread 2ns
  • 36. 0 50 000 100 000 150 000 200 000 250 000 1 thread no lock 1 thread with lock 2 threads 3 threads 4 threads 5 threads ops/s per thread global ops/s 5µs
  • 37. 0 2 000 000 4 000 000 6 000 000 8 000 000 10 000 000 12 000 000 1 thread 2 threads 3 threads 4 threads 5 threads 99 99,5 99,99 99,999 max 5µs
  • 38.
  • 39.
  • 41.
  • 42. Cache Cache CORE 0 Thread A CPU Memory CORE 1 Thread B
  • 43. Cache Cache CORE 0 Thread A CPU Memory CORE 1
  • 45. Cache Cache CORE 0 Thread A CPU Memory CORE 1 Thread B
  • 46. Cache Cache CORE 0 Thread A CPU Memory CORE 1 Thread B
  • 47. Cache Cache CORE 0 Thread A CPU Memory CORE 1 Thread B
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59. List<int> list = new List<int>(); foreach (var i in list) { // Do something } IList<int> list = new List<int>(); foreach (var i in list) { // Do something }
  • 60. public Enumerator GetEnumerator() { // Enumerator is a struct return new Enumerator(this); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(this); // boxing } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(this); // boxing }
  • 62. Var c = new Cucumber(); c.Dispose(); IL_0000: ldloca.s c IL_0002: initobj Cucumber IL_0008: ldloca.s c IL_000a: call instance void Cucumber::Dispose()
  • 63. Idisposable c = new Cucumber(); c.Dispose(); IL_0000: ldloca.s CS$0$0000 IL_0002: initobj Cucumber IL_0008: ldloc.1 IL_0009: box Cucumber IL_000e: stloc.0 IL_000f: ldloc.0 IL_0010: callvirt instance void IDisposable::Dispose()
  • 64. using(var c = new Cucumber()) { } IL_0000: ldloca.s c IL_0002: initobj Cucumber .try { IL_0008: leave.s IL_0018 } finally { IL_000a: ldloca.s c IL_000c: constrained. Cucumber IL_0012: callvirt instance void IDisposable::Dispose() IL_0017: endfinally }
  • 65. void DoSomething(IDisposable arg) void DoSomething<T>(T arg) where T : IDisposable
  • 66. *
  • 67. [StructLayout(LayoutKind.Sequential)] private struct DecimalProxy { public readonly int flags; public readonly int hi; public readonly int lo; public readonly int mid; }
  • 68. var d = 42m; var decimalProxy = *((DecimalProxy*)(&d)); var flags = decimalProxy.flags; var lo = decimalProxy.lo; var mid = decimalProxy.mid; var hi = decimalProxy.hi; // Enjoy your flags-lo-mid-high!
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74. // using lambda DoSomething(() => Console.WriteLine()); // delegate from method group DoSomething(Console.WriteLine); // capturing local variable DoSomething(() => local++); // capturing field DoSomething(() => _field++);
  • 75. public class NCrafts { private int _field; private void DoSomething(Action action){} public void Test() { DoSomething(() => _field++); } }
  • 76. public class NCrafts { private int _field; private void DoSomething(Action action){} public void Test() { DoSomething(new Action(AnonymousMethod)); } [CompilerGenerated] public void AnonymousMethod() { _field++; } }
  • 77. public class NCrafts { private static int _field; private void DoSomething(Action action){} public void Test() { DoSomething(() => _field++); } }
  • 78. public class NCrafts { [CompilerGenerated] private static Action _cachedDelegate; private static int _field; private static void DoSomething(Action action){} public void Test() { if (_cachedDelegate == null) _cachedDelegate = new Action(Anonymous); DoSomething(_cachedDelegate); } [CompilerGenerated] private static void Anonymous() { _field++; } }
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 86. // low-latency // can be a // business // requirement
  • 87. // it’s hard no // matter what // stack you // rely on
  • 88. // low-latency // in managed // code is a // real option
  • 89. // is there a // trend here? talk.Close(); }