F# for Performance-Critical Code
summary
F# codebase for a discrete‑rate simulation engine hits a concrete goal: rerun a million time steps inside one second — 1 microsecond per step — by replacing naive linear programming with a custom algorithm plus aggressive, measured optimizations. Using BenchmarkDotNet and dotTrace, the implementation moves from maps and hashsets to arrays, bitsets, stack allocation and a compressed sparse row layout, adds branchless IL where needed, and delivers roughly a 100x speedup over an industry engine.
AI-written summary · about
chapters (19)
- 0:00F# for performance-critical code
- 1:05Why F# excels in performance
- 8:11Microsecond budget for performance
- 9:57Replacing linear programming
- 13:27Measuring performance with Benchmark.NET
- 14:30Mutation in F# for speed
- 16:13Right data structures for performance
- 17:59Units of measure for fast equality
- 21:12Minimizing data representation
- 22:58Optimizing memory layout
- 26:12Replacing hash sets with bit arrays
- 29:23Stack allocation to reduce heap
- 32:14Compressed sparse row for graphs
- 35:05Refining algorithms beyond theory
- 38:59Simplifying data structures
- 40:26Branchless programming with inline IL
- 44:26Real-world simulation impact
- 45:29Key takeaways for high-performance F#
- 58:03Q&A
related talks
01h 00mF# for the C# Developer - F#, the .NET Runtime, and Aesthetics
01h 00mF# in the Real World
57mF# Code I Love
01h 04mTurbocharged: Writing High-Performance C# and .NET Code
25m.NET Languages PM and Friends Talk About F#
46mFunctional programming in F# Fad or Fabulous
37mRock Your Code Code and App Performance for Microsoft .Net
56mState of the .NET Performance
