DEV Community

Cover image for SearchValues<T> in .NET 8/9 (.NET & C#)
Maayur Dahake
Maayur Dahake

Posted on

SearchValues<T> in .NET 8/9 (.NET & C#)

SearchValues<T> in .NET 8/9 (.NET & C#)

Day 1/30 — SearchValues in .NET 8/9 (.NET & C#)

Found this gem while tracing Gen0 GC pressure on our text parsing hot path.

• Static caching: SearchValues instances must be static readonly fields to avoid recreation overhead.
• SIMD vectors: JIT compiler auto-vectorizes operations against CPU registers for massive throughput gains.
• Zero allocations: Span-based signatures eliminate managed heap overhead entirely during execution.

Watch out: Creating SearchValues inside a tight loop negates performance gains due to initialization costs.

Are you still using IndexOfAny for parsing?

DotNet #CSharp #Performance #BackendDevelopment #SoftwareEngineering

Top comments (0)