paritytech / polkadot

Polkadot Node Implementation
GNU General Public License v3.0
7.12k stars 1.58k forks source link

Reuse Reed-Solomon encoder #2383

Open burdges opened 3 years ago

burdges commented 3 years ago

erasure_coding::Params::make_encoder should be rather slow, due to building the whole Vandermonde matrix.

We call it for every encoding and decoding operation currently. We only need to invoke it once per validator set size change.

We should either (a) store the resulting ::reed_solomon::galois_16::ReedSolomon type with the validator set, or else (b) memoize it behind a lazy static (CodeParams,Arc<ReedSolomon>), meaning make_encoder clones and return the the Arc if CodeParams stayed the same or replace it otherwise.

burdges commented 3 years ago

Appears there is already caching for the inverted matrix based upon https://github.com/darrenldl/reed-solomon-erasure/issues/74 but this should go away with a better FFT based design.