~/talk

Maximizing Algorithm Performance in .NET: Levenshtein Distance

Talkat JetBrains .NET Days Online 2022 · 2022-10-25..10-26· [dotnet]
slides:none on file

Levenshtein implementation in C# moves from a baseline that takes ~0.5s and allocates ~381MB for 10,000‑char inputs to a chain of concrete wins: replacing the full matrix with a single row cuts allocations and gives ~57% speedup and removes 99.9% of allocations; renting with ArrayPool makes it allocation‑free; small pointer tweaks add ~9%; SIMD with AVX2 plus a diagonal vector algorithm and optional multi‑threading reaches roughly 7–9× faster and scales to 100k chars (benchmarks and Quickenshtein code on GitHub with BenchmarkDotNet).

AI-written summary · about

  1. 0:00Start
  2. 2:13Calculating the distance
  3. 3:35The 3 essential elements of Levenshtein Distance
  4. 3:55Our baseline implementation
  5. 4:58Time/Space Complexity Hurts!
  6. 7:41Understanding the algorithm (Part 2)
  7. 8:59Span-ing Memory
  8. 9:35The performance of trimming
  9. 10:20Let's talk branch prediction
  10. 10:54The performance impact of branches
  11. 11:17Understanding the algorithm (Part 3)
  12. 13:56Source character optimization
  13. 15:30Pointers on all data access
  14. 16:28Current performance progress
  15. 16:46Hardware Intrinsics
  16. 17:16Single Instruction, Multiple Data (SIMD)
  17. 17:33SIMD: Improving trimming logic
  18. 19:46SIMD: Data Initialization
  19. 22:57For even larger strings: Multi-threading
  20. 24:41Understanding the algorithm (Part 4)
  21. 26:06SIMD: Main Calculation (Revisited)
  22. 28:35Having a performance goal
  23. 28:55Measuring performance changes
  24. 29:12How you approach the problem
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.