SlideShare uma empresa Scribd logo
1 de 25
Performance in .NET: Best practices Sorin Oboroceanu, obs@rms.ro Vlad Balan, bav@rms.ro RomSoft, www.rms.ro Iași, 8th of May 2010
Agenda Why performance matters Serialization Reading XML Garbage Collection JITing
Why performance matters Everyone loves performance Performance=money Bing  - 2 seconds slower – 4.3% drop in revenue Google – 400ms slower – 0.6% drop in searches Yahoo! – 400ms slower – 5-9% drop in full page traffic Mozilla – 2.2 seconds faster – increased download conversion 15.4% Site speed is now taken into account in search rankings
Why performance matters Better apps – Satisfied customers
Our Demo APP Uses StackOverflow.com’s data Groups users by location Displays user locations in a chart Will work in a client/server architecture Has performance issues 
Collections Groupping data List<T> LINQ to Objects Dictionary<T,V> DEMO
Client-Server communication Retrieving all users on the client Grouping data List<T> LINQ to Objects Dictionary<T,V> DEMO
Client-Server communication Grouping data on the server List<T> LINQ to Objects Dictionary<T,V> Retrieving only location-related data on the client DEMO
Reading XML DataSet XmlReader LINQ to XML XmlDocument DEMO
Garbage Collection Why memory matters Garbage Collector Object Finalization
Why memory matters Inefficient use of memory can impact Performance Stability Scalability Other Applications Hidden problems in code can cause Memory Leaks Excessive memory usage Unnecessary performance overhead
.NET Memory Management Small Object Heap (SOH) – Objects < 85K Large Object Heap (LOH) – Objects => 85K
Small Object Heap (SOH) GC SmallObjectObjectA = new SmallObject();  SmallObjectObjectB = new SmallObject();  Global Objects Small Object  Heap Next Object Pointer ObjectE Next Object Pointer Stack ObjectD Static Objects Next Object Pointer ObjectC Next Object Pointer ObjectB ObjectB Next Object Pointer ObjectA Root Reference ObjectA Next Object Pointer Child Reference
Generations GC - Gen 0 GC - Gen 1 GC - Gen 2 Small Object  Heap Gen 0 Next Object Pointer Global Objects ObjectD ObjectC Next Object Pointer Gen 1 Static Objects Stack ObjectB Gen 2 Root Reference ObjectA
Large Object Heap (LOH) GC- Gen2 LargeObjectObjectD= new LargeObject();  Global Objects Free space table Large Object  Heap 5727400 425000 16777216 ObjectD 94208 182272 Free space Stack ObjectC ObjectC ObjectB Free space ObjectB ObjectA ObjectA
Finalization GC Finalization Queue FinObjectObjectE = new FinObject();  Small Object  Heap Gen 0 Global Objects ObjectE ObjectE Finalize() ObjectD fReachable Queue Finalizer thread ObjectC Stack Gen 1 ObjectB ObjectB ObjectA ObjectA
Finalization public class Test {  ~Test()  {	Cleanup ();   }  private void Cleanup()  {// clean up unmanaged resources } }
Disposable pattern public class Test : IDisposable{  ~Test()  {	Cleanup (false);   }  private void Cleanup(boolcodeDispose)  {      if (codeDispose)      {	// dispose managed resources        }	// clean up unmanaged resources   }  public void Dispose()  {	Cleanup (true); GC.SuppressFinalize(this);  } }
DEMO
JITing Console static void WriteLine(); static void WriteLine(string); (remaining members) Managed EXE static void Main(){ Console.WriteLine(“Hello”); Console.WriteLine(“GoodBye”); } JITCompiler JITCompiler MSCorEE.dll … JITCompiler function{ Look up the called method in the metadata Get the IL for it from metadata Allocate memory Compile the IL into allocated memory Modify the method’s entry in the Type’s table so it points to allocated memory Jump to the native code contained inside the memory block. } Native CPU instr.
JITing Console static void WriteLine(); static void WriteLine(string); (remaining members) Managed EXE static void Main(){ Console.WriteLine(“Hello”); Console.WriteLine(“GoodBye”); } JITCompiler Native MSCorEE.dll … JITCompiler function{ Lookup the called method in the metadata Get the IL for it from metadata Allocate memory Compile the IL into allocated memory Modify the method’s entry in the Type’s table so it points to allocated memory Jump to the native code contained inside the memory block.} Native CPU instr.
DEMO
Resources CLR via C# 3, Jeffrey Richter www.red-gate.com www.stackoverflow.com
Q&A
Please fill the evaluation formThank you very much! Sorin Oboroceanu, obs@rms.ro Vlad Balan, bav@rms.ro RomSoft, www.rms.ro Iași, 8th of May 2010

Mais conteúdo relacionado

Mais procurados

Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupStartit
 
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)Rodrigo Senra
 
Firebase Golang Binding
Firebase Golang BindingFirebase Golang Binding
Firebase Golang BindingEddy Reyes
 
Tk2323 lecture 9 api json
Tk2323 lecture 9   api jsonTk2323 lecture 9   api json
Tk2323 lecture 9 api jsonMengChun Lam
 
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_nightトークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_nightKenji Tanaka
 
Agile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with NetbeansAgile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with NetbeansCarol McDonald
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxNir Elbaz
 

Mais procurados (12)

Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
 
Android dev 3
Android dev 3Android dev 3
Android dev 3
 
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
Rest - Representational State Transfer (EMC BRDC Internal Tech talk)
 
Firebase Golang Binding
Firebase Golang BindingFirebase Golang Binding
Firebase Golang Binding
 
Elk
Elk Elk
Elk
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
Tk2323 lecture 9 api json
Tk2323 lecture 9   api jsonTk2323 lecture 9   api json
Tk2323 lecture 9 api json
 
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_nightトークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
トークンリフレッシュ処理を含むAPIClientのテスト #hakata_test_night
 
Agile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with NetbeansAgile web development Groovy Grails with Netbeans
Agile web development Groovy Grails with Netbeans
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Logstash
LogstashLogstash
Logstash
 
Ajax
AjaxAjax
Ajax
 

Destaque

Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013   corneliu rimboiu - bridging java and .netIasi code camp 12 october 2013   corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .netCodecamp Romania
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)Chalermpon Areepong
 
Scalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetScalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetBala Subra
 
Authentication, Authorization, and Identity – More than meets the eye…
Authentication, Authorization, and Identity – More than meets the eye…Authentication, Authorization, and Identity – More than meets the eye…
Authentication, Authorization, and Identity – More than meets the eye…Scott Hoag
 
Web API authentication and authorization
Web API authentication and authorization Web API authentication and authorization
Web API authentication and authorization Chalermpon Areepong
 
Asp.net mvc security
Asp.net mvc securityAsp.net mvc security
Asp.net mvc securityLearningTech
 
DDD Melbourne 2014 security in ASP.Net Web API 2
DDD Melbourne 2014 security in ASP.Net Web API 2DDD Melbourne 2014 security in ASP.Net Web API 2
DDD Melbourne 2014 security in ASP.Net Web API 2Pratik Khasnabis
 
Design & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursDesign & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursRestlet
 
Secure RESTful Web Services for ASP.NET Web API
Secure RESTful Web Services for ASP.NET Web APISecure RESTful Web Services for ASP.NET Web API
Secure RESTful Web Services for ASP.NET Web APIRob Daigneau
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuu Nguyen
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsSarvesh Kushwaha
 
ASP.NET Core 1.0 Overview: Post-RC2
ASP.NET Core 1.0 Overview: Post-RC2ASP.NET Core 1.0 Overview: Post-RC2
ASP.NET Core 1.0 Overview: Post-RC2Shahed Chowdhuri
 
Overview of the .Net Collection Framework and Immutable Collections
Overview of the .Net Collection Framework and Immutable CollectionsOverview of the .Net Collection Framework and Immutable Collections
Overview of the .Net Collection Framework and Immutable CollectionsYoshifumi Kawai
 
5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slidesMasterCode.vn
 
ASP.NET Core MVC + Web API with Overview (Post RC2)
ASP.NET Core MVC + Web API with Overview (Post RC2)ASP.NET Core MVC + Web API with Overview (Post RC2)
ASP.NET Core MVC + Web API with Overview (Post RC2)Shahed Chowdhuri
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersoazabir
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websitesoazabir
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 

Destaque (20)

Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013   corneliu rimboiu - bridging java and .netIasi code camp 12 october 2013   corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
 
Scalable Resilient Web Services In .Net
Scalable Resilient Web Services In .NetScalable Resilient Web Services In .Net
Scalable Resilient Web Services In .Net
 
Authentication, Authorization, and Identity – More than meets the eye…
Authentication, Authorization, and Identity – More than meets the eye…Authentication, Authorization, and Identity – More than meets the eye…
Authentication, Authorization, and Identity – More than meets the eye…
 
Web API authentication and authorization
Web API authentication and authorization Web API authentication and authorization
Web API authentication and authorization
 
Asp.net mvc security
Asp.net mvc securityAsp.net mvc security
Asp.net mvc security
 
DDD Melbourne 2014 security in ASP.Net Web API 2
DDD Melbourne 2014 security in ASP.Net Web API 2DDD Melbourne 2014 security in ASP.Net Web API 2
DDD Melbourne 2014 security in ASP.Net Web API 2
 
Smooth Sort
Smooth SortSmooth Sort
Smooth Sort
 
Design & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hoursDesign & Deploy a data-driven Web API in 2 hours
Design & Deploy a data-driven Web API in 2 hours
 
Secure RESTful Web Services for ASP.NET Web API
Secure RESTful Web Services for ASP.NET Web APISecure RESTful Web Services for ASP.NET Web API
Secure RESTful Web Services for ASP.NET Web API
 
End to End Security with MVC and Web API
End to End Security with MVC and Web APIEnd to End Security with MVC and Web API
End to End Security with MVC and Web API
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web Applications
 
Tips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC ApplicationsTips and Tricks For Faster Asp.NET and MVC Applications
Tips and Tricks For Faster Asp.NET and MVC Applications
 
ASP.NET Core 1.0 Overview: Post-RC2
ASP.NET Core 1.0 Overview: Post-RC2ASP.NET Core 1.0 Overview: Post-RC2
ASP.NET Core 1.0 Overview: Post-RC2
 
Overview of the .Net Collection Framework and Immutable Collections
Overview of the .Net Collection Framework and Immutable CollectionsOverview of the .Net Collection Framework and Immutable Collections
Overview of the .Net Collection Framework and Immutable Collections
 
5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides5. web api 2 aspdotnet-mvc5-slides
5. web api 2 aspdotnet-mvc5-slides
 
ASP.NET Core MVC + Web API with Overview (Post RC2)
ASP.NET Core MVC + Web API with Overview (Post RC2)ASP.NET Core MVC + Web API with Overview (Post RC2)
ASP.NET Core MVC + Web API with Overview (Post RC2)
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 

Semelhante a Performance in .net best practices

Performance In The .Net World
Performance In The .Net WorldPerformance In The .Net World
Performance In The .Net WorldVlad Balan
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)Peter Presnell
 
ADF Gold Nuggets (Oracle Open World 2011)
ADF Gold Nuggets (Oracle Open World 2011)ADF Gold Nuggets (Oracle Open World 2011)
ADF Gold Nuggets (Oracle Open World 2011)Lucas Jellema
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaPawanMM
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)Montreal JUG
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWTArnaud Tournier
 
Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Svetlin Nakov
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Darwin Biler
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gMarcelo Ochoa
 
Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Kashif Imran
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkBill Lyons
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?ukdpe
 
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkMaximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkFlink Forward
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application FrameworkSimon Willison
 
Workflow Management with Espresso Workflow
Workflow Management with Espresso WorkflowWorkflow Management with Espresso Workflow
Workflow Management with Espresso WorkflowRolf Kremer
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptjasonsich
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code lessAnton Novikau
 

Semelhante a Performance in .net best practices (20)

Performance In The .Net World
Performance In The .Net WorldPerformance In The .Net World
Performance In The .Net World
 
MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)MWLUG 2014: Modern Domino (workshop)
MWLUG 2014: Modern Domino (workshop)
 
ADF Gold Nuggets (Oracle Open World 2011)
ADF Gold Nuggets (Oracle Open World 2011)ADF Gold Nuggets (Oracle Open World 2011)
ADF Gold Nuggets (Oracle Open World 2011)
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise Java
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
JDBC Part - 2
JDBC Part - 2JDBC Part - 2
JDBC Part - 2
 
EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11g
 
Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache FlinkMaximilian Michels – Google Cloud Dataflow on Top of Apache Flink
Maximilian Michels – Google Cloud Dataflow on Top of Apache Flink
 
The Django Web Application Framework
The Django Web Application FrameworkThe Django Web Application Framework
The Django Web Application Framework
 
Workflow Management with Espresso Workflow
Workflow Management with Espresso WorkflowWorkflow Management with Espresso Workflow
Workflow Management with Espresso Workflow
 
Intro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScriptIntro to React - Featuring Modern JavaScript
Intro to React - Featuring Modern JavaScript
 
How to code to code less
How to code to code lessHow to code to code less
How to code to code less
 

Mais de Codecamp Romania

Cezar chitac the edge of experience
Cezar chitac   the edge of experienceCezar chitac   the edge of experience
Cezar chitac the edge of experienceCodecamp Romania
 
Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-packCodecamp Romania
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pegaCodecamp Romania
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseCodecamp Romania
 
2015 dan ardelean develop for windows 10
2015 dan ardelean   develop for windows 10 2015 dan ardelean   develop for windows 10
2015 dan ardelean develop for windows 10 Codecamp Romania
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous deliveryCodecamp Romania
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2dCodecamp Romania
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdomCodecamp Romania
 
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...Codecamp Romania
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowCodecamp Romania
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in androidCodecamp Romania
 
Kickstart your own freelancing career
Kickstart your own freelancing careerKickstart your own freelancing career
Kickstart your own freelancing careerCodecamp Romania
 
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu   the soft stuff is the hard stuff. the agile soft skills toolkitIonut grecu   the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkitCodecamp Romania
 
Diana antohi me against myself or how to fail and move forward
Diana antohi   me against myself  or how to fail  and move forwardDiana antohi   me against myself  or how to fail  and move forward
Diana antohi me against myself or how to fail and move forwardCodecamp Romania
 

Mais de Codecamp Romania (20)

Cezar chitac the edge of experience
Cezar chitac   the edge of experienceCezar chitac   the edge of experience
Cezar chitac the edge of experience
 
Cloud powered search
Cloud powered searchCloud powered search
Cloud powered search
 
Ccp
CcpCcp
Ccp
 
Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-pack
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pega
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabase
 
Agility and life
Agility and lifeAgility and life
Agility and life
 
2015 dan ardelean develop for windows 10
2015 dan ardelean   develop for windows 10 2015 dan ardelean   develop for windows 10
2015 dan ardelean develop for windows 10
 
The bigrewrite
The bigrewriteThe bigrewrite
The bigrewrite
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous delivery
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2d
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdom
 
Scale net apps in aws
Scale net apps in awsScale net apps in aws
Scale net apps in aws
 
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...Raluca butnaru corina cilibiu   the unknown universe of a product and the cer...
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
 
Parallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflowParallel & async processing using tpl dataflow
Parallel & async processing using tpl dataflow
 
Material design screen transitions in android
Material design screen transitions in androidMaterial design screen transitions in android
Material design screen transitions in android
 
Kickstart your own freelancing career
Kickstart your own freelancing careerKickstart your own freelancing career
Kickstart your own freelancing career
 
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu   the soft stuff is the hard stuff. the agile soft skills toolkitIonut grecu   the soft stuff is the hard stuff. the agile soft skills toolkit
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
 
Ecma6 in the wild
Ecma6 in the wildEcma6 in the wild
Ecma6 in the wild
 
Diana antohi me against myself or how to fail and move forward
Diana antohi   me against myself  or how to fail  and move forwardDiana antohi   me against myself  or how to fail  and move forward
Diana antohi me against myself or how to fail and move forward
 

Performance in .net best practices

  • 1. Performance in .NET: Best practices Sorin Oboroceanu, obs@rms.ro Vlad Balan, bav@rms.ro RomSoft, www.rms.ro Iași, 8th of May 2010
  • 2. Agenda Why performance matters Serialization Reading XML Garbage Collection JITing
  • 3. Why performance matters Everyone loves performance Performance=money Bing - 2 seconds slower – 4.3% drop in revenue Google – 400ms slower – 0.6% drop in searches Yahoo! – 400ms slower – 5-9% drop in full page traffic Mozilla – 2.2 seconds faster – increased download conversion 15.4% Site speed is now taken into account in search rankings
  • 4. Why performance matters Better apps – Satisfied customers
  • 5. Our Demo APP Uses StackOverflow.com’s data Groups users by location Displays user locations in a chart Will work in a client/server architecture Has performance issues 
  • 6. Collections Groupping data List<T> LINQ to Objects Dictionary<T,V> DEMO
  • 7. Client-Server communication Retrieving all users on the client Grouping data List<T> LINQ to Objects Dictionary<T,V> DEMO
  • 8. Client-Server communication Grouping data on the server List<T> LINQ to Objects Dictionary<T,V> Retrieving only location-related data on the client DEMO
  • 9. Reading XML DataSet XmlReader LINQ to XML XmlDocument DEMO
  • 10. Garbage Collection Why memory matters Garbage Collector Object Finalization
  • 11. Why memory matters Inefficient use of memory can impact Performance Stability Scalability Other Applications Hidden problems in code can cause Memory Leaks Excessive memory usage Unnecessary performance overhead
  • 12. .NET Memory Management Small Object Heap (SOH) – Objects < 85K Large Object Heap (LOH) – Objects => 85K
  • 13. Small Object Heap (SOH) GC SmallObjectObjectA = new SmallObject(); SmallObjectObjectB = new SmallObject(); Global Objects Small Object Heap Next Object Pointer ObjectE Next Object Pointer Stack ObjectD Static Objects Next Object Pointer ObjectC Next Object Pointer ObjectB ObjectB Next Object Pointer ObjectA Root Reference ObjectA Next Object Pointer Child Reference
  • 14. Generations GC - Gen 0 GC - Gen 1 GC - Gen 2 Small Object Heap Gen 0 Next Object Pointer Global Objects ObjectD ObjectC Next Object Pointer Gen 1 Static Objects Stack ObjectB Gen 2 Root Reference ObjectA
  • 15. Large Object Heap (LOH) GC- Gen2 LargeObjectObjectD= new LargeObject(); Global Objects Free space table Large Object Heap 5727400 425000 16777216 ObjectD 94208 182272 Free space Stack ObjectC ObjectC ObjectB Free space ObjectB ObjectA ObjectA
  • 16. Finalization GC Finalization Queue FinObjectObjectE = new FinObject(); Small Object Heap Gen 0 Global Objects ObjectE ObjectE Finalize() ObjectD fReachable Queue Finalizer thread ObjectC Stack Gen 1 ObjectB ObjectB ObjectA ObjectA
  • 17. Finalization public class Test { ~Test() { Cleanup (); } private void Cleanup() {// clean up unmanaged resources } }
  • 18. Disposable pattern public class Test : IDisposable{ ~Test() { Cleanup (false); } private void Cleanup(boolcodeDispose) { if (codeDispose) { // dispose managed resources } // clean up unmanaged resources } public void Dispose() { Cleanup (true); GC.SuppressFinalize(this); } }
  • 19. DEMO
  • 20. JITing Console static void WriteLine(); static void WriteLine(string); (remaining members) Managed EXE static void Main(){ Console.WriteLine(“Hello”); Console.WriteLine(“GoodBye”); } JITCompiler JITCompiler MSCorEE.dll … JITCompiler function{ Look up the called method in the metadata Get the IL for it from metadata Allocate memory Compile the IL into allocated memory Modify the method’s entry in the Type’s table so it points to allocated memory Jump to the native code contained inside the memory block. } Native CPU instr.
  • 21. JITing Console static void WriteLine(); static void WriteLine(string); (remaining members) Managed EXE static void Main(){ Console.WriteLine(“Hello”); Console.WriteLine(“GoodBye”); } JITCompiler Native MSCorEE.dll … JITCompiler function{ Lookup the called method in the metadata Get the IL for it from metadata Allocate memory Compile the IL into allocated memory Modify the method’s entry in the Type’s table so it points to allocated memory Jump to the native code contained inside the memory block.} Native CPU instr.
  • 22. DEMO
  • 23. Resources CLR via C# 3, Jeffrey Richter www.red-gate.com www.stackoverflow.com
  • 24. Q&A
  • 25. Please fill the evaluation formThank you very much! Sorin Oboroceanu, obs@rms.ro Vlad Balan, bav@rms.ro RomSoft, www.rms.ro Iași, 8th of May 2010