introduce bucket map (#19848)

* introduce bucket map

* rename BucketMap bits to num_buckets_pow2

* use u64::BITS

* Store the number of buckets in BucketMapConfig as a regular number

* remove redundant type aliases

* use Slot from sdk

* use Arc::clone() instead

* fixup erase drives

* rename num_buckets to max_buckets

* add doc to BucketMapConfig::new()

* add more documentation

* rename to DEFAULT_CAPACITY_POW2

* doc

* add more traits while we can

* rename capacity to capacity_pow2

* fix a naming for max_buckets_pow2

* remove unused/incorrect DataBucket::bytes

* rework benches a bit

* fixup bench docs

* rename create_bucket_capacity_pow2 to bucket_capacity_when_created_pow2

* rename BucketMapKeyValue to BucketItem

* rename to items_in_range

* remove values()

* remove addref and unref

* remove more addref and unref

* resurect addref and unref since tests use 'em for now

* rename to BucketStorage

* move stats in bucket_stats

* remove specializations (i don't think they are needed)

* move MaxSearch and RefCount into lib.rs

* move BucketItem to bucket_item.rs

* add doc

* keys no longer returns an option

* Revert "remove specializations (i don't think they are needed)"

This reverts commit b22f78e072.

Co-authored-by: Brooks Prumo <brooks@solana.com>
This commit is contained in:
Jeff Washington (jwash)
2021-09-17 15:11:27 -05:00
committed by GitHub
parent cddb9da4f0
commit b2152be3b2
14 changed files with 1552 additions and 3 deletions

View File

@ -873,6 +873,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "fs_extra"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
[[package]]
name = "futures"
version = "0.3.17"
@ -1481,6 +1487,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memmap2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4"
dependencies = [
"libc",
]
[[package]]
name = "memmap2"
version = "0.4.0"
@ -2784,6 +2799,21 @@ dependencies = [
"solana-program 1.8.0",
]
[[package]]
name = "solana-bucket-map"
version = "1.8.0"
dependencies = [
"fs_extra",
"log",
"memmap2 0.2.3",
"rand 0.7.3",
"rayon",
"solana-logger 1.8.0",
"solana-measure",
"solana-sdk",
"tempfile",
]
[[package]]
name = "solana-clap-utils"
version = "1.8.0"
@ -3214,6 +3244,7 @@ dependencies = [
"rustc_version 0.4.0",
"serde",
"serde_derive",
"solana-bucket-map",
"solana-compute-budget-program",
"solana-config-program",
"solana-ed25519-program",