- Working with collections
- Improving startup times
- Reducing GC pressure
Another collection group is trees; examples are SortedDicitionary and SortedSet which have efficient lookup but they have an even bigger space requirement per item than linke lists. There are also associative collections such as Dicitionary and HashSet which is somewhere in between LinkedList and Arrays in space requirements.
There are use cases when the existing collections does not fit well, for instance finding words that begin with a specific prefix. Structures that handles this kind of scenario are called Tries.
The key point is that for certain scenarios using a custom collection can boost performance.
Startup can be separated in cold startup and warm startup. Cold startups are when the application has not executed since last reboot, this startup time is dominated by disk I/O operations e.g. loading assemblies and similar. For warm starups JIT compiling and similar is the biggest problem
To improve startup time NGen can be used to compile the .NET code to native code which will speed up load times. Another trick is to enabled Multi-Core background JIT by using ProfileOptimization.SetProfileRoot and ProfileOptimizations.StartProfile. Another solution is to use the faster RyuJIT compiler, however it is not released yet so it might not be 100% stable. It will be part of Visual Studio 2015 and .NET Framework 4.6 release.
To improve cold startup all the assemblies can be merged together and this can be done with ILMerge. Another approach is to use .NET Native that compiles everything down to a single native executable. This removes the need to having the .NET Framework installed on the target machine. However .NET Native is only available for Windows Store Apps.
For optimizing GC handling there are many performance metrics:
- Performance Counters
- Event Tracing for Windows
- Memory Dumps
Finally: don’t use finalization.
This has been the absolute best for me so far at the conference
No comments:
Post a Comment