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
Try
statements to handle exceptions. -
Use the
Stack
class to allocate and manage memory on the stack. - Use memory-mapped files for large data sets.
-
Use the
Span
class to manipulate memory instead of arrays. -
Avoid using
foreach
loops for large collections. - Use parallel loops for parallel processing.
-
Use
Task.Run
to run tasks asynchronously. -
Use
CancellationToken
to cancel tasks. -
Use
SemaphoreSlim
to limit concurrent access to resources. -
Use
ReaderWriterLockSlim
to synchronize access to resources. -
Use
ConcurrentQueue<T>
to synchronize access to queues. -
Use
ConcurrentDictionary<T>
to synchronize access to dictionaries. -
Use
Task
to run tasks asynchronously. -
Use
Semaphore
to limit concurrent access to resources. -
Use
Mutex
to synchronize access to resources. -
Use
Monitor
to synchronize access to resources. -
Use
ReaderWriterLock
to 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
CancellationToken
to cancel tasks. -
Use
Task cancellation token
to cancel tasks. -
Use
TaskCreationOptions
to specify options for creating tasks. -
Use
TaskScheduler
to customize the scheduling of tasks.