FS

F# Performance

Performance optimization patterns for F# code on .NET

Details

Language / Topic
fsharpF#
Category
Performance

Rules

balanced
- Use `[<Struct>]` attribute on small discriminated unions and records to allocate them on the stack and reduce GC pressure.
- Use `Seq` lazily for large collections; prefer `Array` over `List` for random-access and high-throughput processing.
- Use `ValueOption<'T>` instead of `Option<'T>` in performance-critical paths to avoid heap allocation for optional values.
- Use `Array.Parallel.map` and `Async.Parallel` for CPU-bound parallel workloads instead of manual `Task` management.