raft-rs
raft-rs copied to clipboard
Try to reduce clones with a library like rental/owning_ref
As mentioned in https://github.com/tikv/tikv/pull/4640#discussion_r281434168, owning_ref might be a useful crate for us to try.
Investigate the library and look for appropriate places where this library can be used to reduce clones.
https://crates.io/crates/owning_ref
Caution: Several commenters expressed concern for the library, noting it seemed relatively unmaintained (https://github.com/tikv/tikv/pull/4640#discussion_r282646161) but rental may also help. (https://github.com/tikv/tikv/pull/4640#pullrequestreview-234099670)
These might be good things to try, for sure. I would also like to try just using some explicit lifetimes. Usually (not always of course) refactoring code to fit with lifetimes results in better code, even if it is a big overhaul.
@BusyJay found a way to reduce the clone of entries, but the benchmark result was not improved largely.
Please send the PR @BusyJay