Skip to content

Commit a12c46a

Browse files
committed
Release v0.4.0: Major performance optimizations and algorithmic improvements
This release implements comprehensive optimizations inspired by the C++ ripser implementation, resulting in significant performance improvements while maintaining 100% numerical accuracy. ## Performance Improvements - Median speedup: 1.01x | Mean: 1.13x - Top speedups up to 1.82x on certain datasets - Memory usage remains stable (1.01x ratio) - 100% accuracy maintained across all test cases ## Major Optimizations Implemented ### Hot Path Optimizations - **Dense edge generation**: Replaced O(n²×n) reverse iteration with efficient row-by-row generation, eliminating vertex decoding overhead - **Sparse matrix queries**: Implemented binary search for O(log k) distance lookups instead of O(k) linear search - **Binomial coefficient table**: Switched to k-major (transposed) layout for better cache locality during typical access patterns - **k=2 fast path**: Added closed-form sqrt solution for common edge operations ### Algorithmic Improvements - **Sparse coboundary enumeration**: Implemented proper neighbor intersection algorithm, dramatically reducing cofacet generation for sparse graphs - **Zero-apparent pairs**: Added boundary/coboundary pivot detection to skip redundant column reductions in higher dimensions ### Memory and Data Structure Optimizations - **Structure of Arrays (SoA)**: Replaced AoS with SoA layout in reduction matrix for improved cache performance during column operations - **Memory pooling**: Implemented buffer reuse strategies and thread-local pools to reduce allocation overhead - **Capacity management**: Added intelligent buffer sizing with growth strategies to minimize reallocations ### Compilation and Runtime Optimizations - **Global allocator**: Switched to mimalloc for better performance with frequent small allocations - **Link-time optimization**: Enabled LTO, optimized codegen units, and panic=abort for smaller, faster binaries - **Aggressive inlining**: Added #[inline(always)] to critical hot-path functions identified through profiling ## Technical Details All optimizations maintain full compatibility with the original ripser algorithm while implementing the performance strategies from the highly optimized C++ reference implementation. The changes include both micro-optimizations (inlining, memory layout) and macro-optimizations (algorithmic improvements, data structure redesign). ## Testing and Validation - ✅ All accuracy tests pass (6/6) with 100% match to original ripser.py - ✅ Extensive benchmarking across 54 dataset/parameter combinations - ✅ Memory usage profiling confirms stable resource consumption - ✅ Cross-platform compatibility maintained Breaking changes: None - API remains fully backward compatible.
1 parent 4a0b9f0 commit a12c46a

File tree

2 files changed

+495
-129
lines changed

2 files changed

+495
-129
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "canns-ripser"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
edition = "2021"
5-
description = "Rust implementation of Ripser for topological data analysis, optimized for CANNS library"
5+
description = "High-performance Rust implementation of Ripser for topological data analysis, with algorithmic optimizations inspired by C++ ripser"
66
license = "Apache-2.0"
77
authors = ["Sichao He <[email protected]>"]
88
homepage = "https://github.com/routhleck/canns-ripser"
@@ -26,6 +26,7 @@ num-traits = "0.2"
2626
indexmap = "2.0"
2727
rustc-hash = "1.1"
2828
typed-arena = "2.0"
29+
mimalloc = { version = "0.1.43", default-features = false }
2930

3031
[build-dependencies]
3132
pyo3-build-config = "0.20"

0 commit comments

Comments
 (0)