Skip to content

Commit

Permalink
Merge pull request #61 from darrenldl/dev
Browse files Browse the repository at this point in the history
Misc fixes, ideally final PR before 4.0.0 release
  • Loading branch information
darrenldl committed Sep 21, 2019
2 parents 29102be + 1029d2a commit fa406ee
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern crate reed_solomon_erasure;

use reed_solomon_erasure::galois_8::ReedSolomon;
// or use the following for Galois 2^16 backend
// use reed_solomon_erasure::galois_8::ReedSolomon;
// use reed_solomon_erasure::galois_16::ReedSolomon;

fn main () {
let r = ReedSolomon::new(3, 2).unwrap(); // 3 data shards, 2 parity shards
Expand Down Expand Up @@ -76,10 +76,10 @@ fn main () {
```

## Benchmark it yourself
You can test performance under different configurations quickly(e.g. data parity shards ratio, parallel parameters)
You can test performance under different configurations quickly (e.g. data parity shards ratio, parallel parameters)
by cloning this repo: https://github.com/darrenldl/rse-benchmark

`rse-benchmark` contains a copy of this library(usually a fully functional dev version), so you only need to adjust `main.rs`
`rse-benchmark` contains a copy of this library (usually a fully functional dev version), so you only need to adjust `main.rs`
then do `cargo run --release` to start the benchmark.

## Performance
Expand All @@ -91,10 +91,12 @@ Machine: laptop with `Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (max 2.70GHz) 2 C

Below shows the result of one of the test configurations, other configurations show similar results in terms of ratio.

|Configuration| Klaus Post's | >= 2.1.0 | 2.0.X | 1.X.X |
|Configuration| Klaus Post's | >= 2.1.0 && < 4.0.0 | 2.0.X | 1.X.X |
|---|---|---|---|---|
| 10x2x1M | ~7800MB/s |~4500MB/s | ~1000MB/s | ~240MB/s |

Versions `>= 4.0.0` have not been benchmarked thoroughly yet

## Changelog
[Changelog](CHANGELOG.md)

Expand Down
18 changes: 16 additions & 2 deletions src/galois_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ mod tests {
}
}

fn qc_exponent(a: Element, n: u8) -> bool {
n == 0 || {
fn qc_exponent_1(a: Element, n: u8) -> bool {
a.is_zero() || n == 0 || {
let mut b = a.exp(n as usize);
for _ in 1..n {
b = b / a;
Expand All @@ -380,6 +380,20 @@ mod tests {
}
}

fn qc_exponent_2(a: Element, n: u8) -> bool {
a.is_zero() || {
let mut res = true;
let mut b = Element::constant(1);

for i in 0..n {
res = res && b == a.exp(i as usize);
b = b * a;
}

res
}
}

fn qc_exp_zero_is_one(a: Element) -> bool {
a.exp(0) == Element::constant(1)
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use std::iter::{self, FromIterator};
#[macro_use]
mod macros;

mod core;
mod errors;
mod inversion_tree;
mod matrix;
mod core;

#[cfg(test)]
mod tests;
Expand All @@ -40,8 +40,8 @@ pub mod galois_8;
pub use crate::errors::Error;
pub use crate::errors::SBSError;

pub use crate::core::ShardByShard;
pub use crate::core::ReedSolomon;
pub use crate::core::ShardByShard;

/// A finite field to perform encoding over.
pub trait Field: Sized {
Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// # use reed_solomon_erasure::*;
/// # fn main () {
/// let shards: Vec<Vec<u8>> = shards!([1, 2, 3],
/// [4, 5, 6]);
/// [4, 5, 6]);
/// # }
/// ```
#[macro_export]
Expand Down Expand Up @@ -37,7 +37,7 @@ macro_rules! shards {
/// # #[macro_use] extern crate reed_solomon_erasure;
/// # fn main () {
/// let mut array: [[u8; 3]; 2] = [[1, 2, 3],
/// [4, 5, 6]];
/// [4, 5, 6]];
///
/// let refs: Vec<&mut [u8]> =
/// convert_2D_slices!(array =>to_mut_vec &mut [u8]);
Expand All @@ -50,7 +50,7 @@ macro_rules! shards {
/// # use smallvec::SmallVec;
/// # fn main () {
/// let mut array: [[u8; 3]; 2] = [[1, 2, 3],
/// [4, 5, 6]];
/// [4, 5, 6]];
///
/// let refs: SmallVec<[&mut [u8]; 32]> =
/// convert_2D_slices!(array =>to_mut SmallVec<[&mut [u8]; 32]>,
Expand Down

0 comments on commit fa406ee

Please sign in to comment.