Your SlideShare is downloading. ×
0
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Performance In The .Net World
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Performance In The .Net World

362

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
362
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Performance in the .NET world. A developer’s perspective<br />Sorin Oboroceanu, Vlad Balan<br />RomSoft, www.rms.ro<br />Iaşi, May 4th 2010<br />
  • 2. Agenda<br />String vs. StringBuilder<br />Serialization<br />Reading XML<br />Garbage Collection<br />JITing<br />2<br />
  • 3. String vs. StringBuilder<br />3<br />DEMO<br />
  • 4. Our Demo APP<br />Uses StackOverflow.com’s data<br />Groups users by location<br />Displays user locations in a chart<br />Will work in a client/server architecture<br />Has performance issues <br />4<br />
  • 5. Collections<br />Groupping data<br />List&lt;T&gt;<br />LINQ to Objects<br />Dictionary&lt;T,V&gt;<br />5<br />DEMO<br />
  • 6. Client-Server communication<br />Retrieving all users on the client<br />Grouping data<br />List&lt;T&gt;<br />LINQ to Objects<br />Dictionary&lt;T,V&gt;<br />6<br />DEMO<br />
  • 7. Client-Server communication<br />Grouping data on the server<br />List&lt;T&gt;<br />LINQ to Objects<br />Dictionary&lt;T,V&gt;<br />Retrieving only location-related data on the client<br />7<br />DEMO<br />
  • 8. Reading XML<br />DataSet<br />XmlReader<br />LINQ to XML<br />XmlDocument<br />8<br />DEMO<br />
  • 9. Garbage Collection<br />Why memory matters<br />Garbage Collector<br />Common Memory Issues<br />Diagnosing Memory Problems <br />9<br />
  • 10. Why memory matters<br />Inefficient use of memory can impact<br />Performance<br />Stability<br />Scalability<br />Other Applications<br />Hidden problems in code can cause<br />Memory Leaks<br />Excessive memory usage<br />Unnecessary performance overhead<br />10<br />
  • 11. GC – Small Object Heap (SOH)<br />11<br />GC<br />SmallObjectObjectA = new SmallObject(); <br />SmallObjectObjectB = new SmallObject(); <br />Global Objects<br />Small Object Heap<br />Next Object Pointer<br />ObjectE<br />Next Object Pointer<br />Stack<br />ObjectD<br />Static Objects<br />Next Object Pointer<br />ObjectC<br />Next Object Pointer<br />ObjectB<br />ObjectB<br />Next Object Pointer<br />ObjectA<br />ObjectA<br />Root Reference<br />Next Object Pointer<br />Child Reference<br />
  • 12. GC- Gen2<br />LargeObjectObjectD= new LargeObject(); <br />Global Objects<br />Free space table<br />Large Object Heap<br />425000<br />16777216<br />ObjectD<br />5727400<br />94208<br />182272<br />Free space<br />Stack<br />ObjectC<br />ObjectC<br />ObjectB<br />Free space<br />ObjectB<br />ObjectA<br />ObjectA<br />12<br />12<br />
  • 13. 13<br />GC - Gen 0<br />GC - Gen 1<br />GC - Gen 2<br />Small Object Heap<br />Gen 0<br />Next Object Pointer<br />Global Objects<br />ObjectD<br />ObjectC<br />Next Object Pointer<br />Gen 1<br />Static Objects<br />Stack<br />ObjectB<br />Gen 2<br />ObjectA<br />Root Reference<br />
  • 14. GC – Minimizing Overhead<br />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); } }<br />14<br />
  • 15. GC – Common Memory Issues<br />Excessive RAM Footprint<br />App allocates objects too early or for too long using more memory than needed<br />Can affect other apps on the system<br />Excessive Temporary Object allocation<br />Garbage Collection runs more frequently<br />Executing threads freeze during Garbage Collection<br />Memory Leaks<br />Overlooked root references keep objects alive (Collections, array, session state, delegates/events)<br />Incorrect or absent Finalization can cause resources leaks<br />15<br />
  • 16. DEMO<br />16<br />
  • 17. JITing<br />17<br />Console<br />static void WriteLine();<br />static void WriteLine(string);<br />(remaining members)<br />Managed EXE<br />static void Main(){<br />Console.WriteLine(“Hello”);<br />Console.WriteLine(“GoodBye”);<br />}<br />JITCompiler<br />JITCompiler<br />MSCorEE.dll<br />…<br />JITCompiler function{<br />Look up the called method in the metadata<br />Get the IL for it from metadata<br />Allocate memory<br />Compile the IL into allocated memory<br />Modify the method’s entry in the Type’s table so it points to allocated memory<br />Jump to the native code contained inside the memory block.<br />}<br />Native CPU instr.<br />
  • 18. JITing<br />18<br />Console<br />static void WriteLine();<br />static void WriteLine(string);<br />(remaining members)<br />Managed EXE<br />static void Main(){<br />Console.WriteLine(“Hello”);<br />Console.WriteLine(“GoodBye”);<br />}<br />JITCompiler<br />Native<br />MSCorEE.dll<br />…<br />JITCompiler function{<br />Lookup the called method in the metadata<br />Get the IL for it from metadata<br />Allocate memory<br />Compile the IL into allocated memory<br />Modify the method’s entry in the Type’s table so it points to allocated memory<br />Jump to the native code contained inside the memory block.}<br />Native CPU instr.<br />
  • 19. DEMO<br />19<br />
  • 20. Resources<br />CLR via C# 3, Jeffrey Richter<br />www.red-gate.com<br />www.stackoverflow.com<br />MSDN<br />20<br />
  • 21. Q&amp;A<br />21<br />
  • 22. 22<br />Please fill the evaluation form<br />Thank you very much!<br />Sorin Oboroceanu, Vlad Balan<br />RomSoft, www.rms.ro<br />Iasi, May 4th 2010<br />

×