We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Performance tricks I learned from contributing to the Azure .NET SDK - Daniel Marbach - NDC Porto
Discover performance tricks from contributing to the Azure.NET SDK, including array pooling, stack allocation, and concurrent collections for efficient memory management and parallel processing.
- Be aware of closure allocations and reuse buffers for small and local buffers.
- Use the array pool for allocating small arrays.
- Use stack allocation for small buffers.
- Avoid unnecessary boxing.
- Use concrete collection types instead of generic ones.
-
Consider using
Trystatements to handle exceptions. -
Use the
Stackclass to allocate and manage memory on the stack. - Use memory-mapped files for large data sets.
-
Use the
Spanclass to manipulate memory instead of arrays. -
Avoid using
foreachloops for large collections. - Use parallel loops for parallel processing.
-
Use
Task.Runto run tasks asynchronously. -
Use
CancellationTokento cancel tasks. -
Use
SemaphoreSlimto limit concurrent access to resources. -
Use
ReaderWriterLockSlimto synchronize access to resources. -
Use
ConcurrentQueue<T>to synchronize access to queues. -
Use
ConcurrentDictionary<T>to synchronize access to dictionaries. -
Use
Taskto run tasks asynchronously. -
Use
Semaphoreto limit concurrent access to resources. -
Use
Mutexto synchronize access to resources. -
Use
Monitorto synchronize access to resources. -
Use
ReaderWriterLockto synchronize access to resources. -
Use
ConcurrentBag<T>to synchronize access to bags. -
Use
ConcurrentStack<T>to synchronize access to stacks. -
Use
ConcurrentQueue<T>to synchronize access to queues. -
Use
ConcurrentDictionary<T>to synchronize access to dictionaries. -
Use
TaskCompletionSource<T>to create tasks that can complete with data. -
Use
CancellationTokento cancel tasks. -
Use
Task cancellation tokento cancel tasks. -
Use
TaskCreationOptionsto specify options for creating tasks. -
Use
TaskSchedulerto customize the scheduling of tasks.