Performance considerations while architecting dot net applications.
- Throwing Few Exceptions :
- Avoid exceptions with in loops.
- Minimal use of functions like Response.Redirect() which throws a ThreadAbort exception.
- COM usage could result in HRESULTS exception, make sure to track these.
- Usages of ValueTypes where ever possible, rather using Reference types that is classes. Avoiding boxing and un-boxing for best use of memory.
- Reduce interaction with unmanaged code. COM interop is much more expensive.The following steps needs to be taken while interacting with unmanaged code.
- Data Marshalling
- fix calling convention
- Protect callee-saved registeres
- Switch thread mode so that GC won't block unmanaged threads
- Erect an Exception Handling frame on calls into managed code
- Handle threading properly
- Use For loop for string iteration. For loop on strings is five times faster than Foreach.
- StringBuilder for complex string manipulation increases performance.
- System.IO buffer size could be between 4KB and 8KB for best performance
- Asynchronous IO when applied correctly, it gives as much as ten times the performance.
Comments