Topics / Avoiding allocations

Performance topic

Avoiding allocations

Fewer heap allocations: reuse buffers, reserve capacity, small-size optimization, stack storage, and moving instead of copying.

4,644proven techniques
98pitfalls: tried, then slower
1,187repositories
86from papers

Examples from real commits

dotnet/runtime 8.6× Copy-on-write map: on update of an existing key, clone only the key/value array and share the immutable bucket and chain arrays. proof: commit → EnzymeAD/Enzyme 1.5× Rewrite the negating header phi in closed form x_0 * (1 - 2*(I - 2*(I/2))) from the canonical induction variable, so the reverse pass recomputes the sign instead of caching it. proof: commit →

Languages

  • C++1,969
  • Rust755
  • C561
  • Go420
  • Python360
  • C#91

Hardware

  • CPU1,039
  • NVIDIA GPU274
  • x86263
  • GPU184
  • ARM90

Fields

  • general1,530
  • data & compression1,113
  • graphics484
  • compilers460
  • math446

Where these come from

Repositories with the most techniques on this topic in the database:

JuliaSmoothOptimizers/Krylov.jl · 22cilium/ebpf · 21golang/go · 21dotnet/runtime · 20FalkorDB/FalkorDB · 19HelixDB/helix-db · 18facebookincubator/MetaPython · 17cilium/cilium · 17python/cpython · 16weaviate/weaviate · 16

Ask Claude for the full answer

Each technique comes with its bottleneck, measured speedup, trade-offs, conditions and the commit or paper behind it, served to Claude through MCP.

claude mcp add --transport http adtomic https://www.adtomic.co/mcp

Connect Claude Pricing

Related topics

Early exit and pruningBit tricks and strength reductionBatchingSpecialization, templates and JITReducing synchronization