AsherJingkongChen / floating-distance

Measure distance between floating-point vectors in Rust
https://docs.rs/floating-distance
MIT License
1 stars 0 forks source link

Update to v0.2.0 #1

Closed AsherJingkongChen closed 1 year ago

AsherJingkongChen commented 1 year ago

Changelog (Dev)

Description

The update introduces a new feature called "simd" that enhances performance. Several tests have been conducted to verify the functionality of the new feature. Additionally, documentation has been added to provide information and instructions on how to use the feature effectively. A simple benchmark and its report provides insights into the performance improvements achieved by the "simd" feature. The CI (Continuous Integration) script has been updated with additional tasks to ensure the overall code quality and maintain standards.

Details

"simd" feature

We take advantages of standard library's iterators and its experimental feature "portable_simd" (RFC 2948). When the "simd" feature is disabled, stub types and traits are exposed to the public (AutoSimd*), ensuring clear documentation even without SIMD support. The implementation of the portable SIMD library is simplified using the auto* macros and cfg_if conditional compilation, making it easier for developers to utilize the library.

Reduce duped implementations

The use of the metric_iterative_impl macro has reduced half of original implementations for distance algorithms.

Trait bounds

We use num_traits::Float and std::simd::SimdFloat. These bounds are chosen for their simplicity and ease of use in the context of the implementation.

Behavior definitions

It is stated that padding vectors with a shorter length is not feasible or sensible due to the performance impact of reallocations. Instead, truncation is used as it does not require reallocation and allows for predictable results. All vectors are truncated to align with the shortest one.

Miscellaneous

Compared to v0.1.0, This repo gained 800 lines in v0.2.0. About 60% of them are tests and source codes take only 20%. Perhaps we can have a way to write more readable tests.