Performance

Study Performance

Big-O, memory allocation, optimization

Topics

Memory Allocation Discipline Example

Senior

“I design for allocation discipline — especially in tight loops. For example, in our tick processor, we rent buffers from ArrayPool, parse with Span and Utf8Parser to avoid string and array allocations, and use small readonly…

Memory Allocation Discipline Example Async

Senior

Study notes and examples

O1 Constant Time

Foundational

O(1) constant time means the work an operation does never grows with the size of the input — a million-entry dictionary lookup costs the same as a ten-entry one. Reaching it usually means choosing the right structure (hash tables,…

OLogN Logarithmic Time

Foundational

O(log n) logarithmic time means each step throws away a constant fraction of the remaining work — doubling the data only adds one more step. This is the regime of binary search, balanced trees (SortedSet, SortedDictionary) and B-tree…

ON Linear Time

Foundational

O(n) linear time means runtime grows in step with the input — doubling the data doubles the work. It's the floor for any algorithm that must look at every element (sums, filters, max/min, table scans), so the senior-engineer move is to…

ON2 Quadratic Time

Mid-level

O(n²) quadratic time grows with the square of the input — double the data and the work quadruples. It's the signature of nested loops over the same collection, Contains against a List inside a loop, and naive string concatenation,…

ONLogN Linearithmic Time

Mid-level

O(n log n) linearithmic time is the cost of touching every element while also dividing the problem in half — the proven lower bound for comparison-based sorting, and the complexity of OrderBy, List.Sort, mergesort, heapsort, and most…

Space Complexity

Mid-level

Space complexity measures how much memory an algorithm needs as input grows, and it's the other half of the performance picture next to time. Senior engineers actively trade between the two — caching turns O(n) lookups into O(1) at the…