The Story Behind the Fastest Image Comparison Library
summary
Library odiff claims fastest in world (benchmarks) for pixel-by-pixel image diffs, implemented in OCaml with a bit of C and tuned by avoiding boxing, using unboxed floats, and comparing raw integer pixels to skip heap allocations. Decoding moves from caml_images to bigarray plus libjpeg-turbo/libpng, cutting costly per-row allocations. GC is tuned (16 MB heap, ~80 minor and 6 major collections for huge runs, majors <1 ms). Cross-compiles to Windows, migrated to OCaml 5.2, and ships via npm packaging.
AI-written summary · about
chapters (11)
- 0:00Introduction to odiff
- 2:29Project origin and approach
- 7:38Profiling and inefficiencies
- 10:56Optimizing OCaml assembly
- 18:20Focusing on real performance
- 20:35Improving comparison logic
- 24:25GC tuning for performance
- 27:32Image decoding bottlenecks
- 30:39Windows support challenges
- 33:47Modernizing the build system
- 37:10Q&A and conclusion
