Optimize BFV dot_product_scalar #370
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Optimize BFV dot_product_scalar by removing redundant iterator traversals
Previously,
dot_product_scalarcloned the input iterators multiple times (for counting, parameter validation, and part length validation) before finally iterating for computation. This added unnecessary overhead.This change collects the zipped input iterators into a
Vec<(&Ciphertext, &Plaintext)>once. Validation and computation then iterate over this vector. This avoids redundant passes and iterator cloning.Performance benchmarks (
bfv_optimized_ops) show mixed results due to allocation overhead for very fast operations, but significant improvements (up to 36%) for some medium-sized workloads (e.g., size=1000, degree=2048) and improved code clarity/safety by validating on the effective input set.PR created automatically by Jules for task 4339254808930472403 started by @tlepoint