uses structural sharing for stake-delegations hash-map (#23585)

StakeDelegations is using Arc to implement copy-on-write semantics:
https://github.com/solana-labs/solana/blob/58c0db970/runtime/src/stake_delegations.rs#L14-L16

However a single delegation change will still clone the entire hash-map,
resulting in excessive memory use as observed in:
https://github.com/solana-labs/solana/issues/23061#issuecomment-1063444072

This commit instead uses immutable hash-map implementing structural
sharing:
> which means that if two data structures are mostly copies of each
> other, most of the memory they take up will be shared between them.
https://docs.rs/im/latest/im/
This commit is contained in:
behzad nouri
2022-03-16 12:58:05 +00:00
committed by GitHub
parent 584ac80b1e
commit 3252dc7203
10 changed files with 118 additions and 145 deletions

View File

@@ -22,6 +22,7 @@ dashmap = { version = "4.0.2", features = ["rayon", "raw-api"] }
dir-diff = "0.3.2"
flate2 = "1.0.22"
fnv = "1.0.7"
im = { version = "15.0.0", features = ["rayon", "serde"] }
index_list = "0.2.7"
itertools = "0.10.3"
lazy_static = "1.4.0"