1.0.0 to 1.2.x2.0.0 to 2.2.xThis document focuses on usage-level differences and migration guidance.
2.0.0,2.1+,2.2+.| Area | 1.x | 2.x |
|---|---|---|
| Shard-count safety | very large shard_count could cause memory pressure |
default MAX_SHARDS guard, plus strict constructors |
| Constructor strategy | mostly direct constructors | compatibility + capped + strict constructor paths |
| Dynamic rebalance | not available | rebalance_to, start_rebalance_online, advance_rebalance |
| Snapshot strategy | traditional path | SnapshotMode::{Clone, Cached, Cow} |
| Migration effort | - | low for default usage, incremental for advanced usage |
2.0.0)New practical behavior in 2.x:
with_shards_and_hasher_capped(...)ShardCountError):
try_with_shards_and_hasher(...)try_with_shards_and_hasher_capped(...)Recommended for external/user-driven configs:
use starshard::ShardedHashMap;
use rustc_hash::FxBuildHasher;
let map = ShardedHashMap::<String, i32>::try_with_shards_and_hasher_capped(
4096,
FxBuildHasher,
8192,
)?;
Migration note:
2.1+)1.x has no dynamic rebalance APIs.
2.1+ adds:
rebalance_to(new_shard_count, options)start_rebalance_online(new_shard_count)advance_rebalance(batch_shards)rebalance_status()use starshard::{RebalanceOptions, ShardedHashMap};
let m: ShardedHashMap<String, i32> = ShardedHashMap::new(8);
m.rebalance_to(32, RebalanceOptions::default())?;
2.2+)2.2+ makes snapshot strategy explicit:
SnapshotMode::Clone (default)SnapshotMode::CachedSnapshotMode::CowAnd adds mode-aware constructors:
with_snapshot_mode(...)with_shards_and_hasher_and_snapshot_mode(...)with_shards_and_hasher_capped_and_snapshot_mode(...)use starshard::{ShardedHashMap, SnapshotMode};
let map: ShardedHashMap<String, i32> =
ShardedHashMap::with_snapshot_mode(64, SnapshotMode::Cached);
batch_insert / batch_remove / batch_get received grouping-path optimizations in 2.0.compute_if_present path was aligned to avoid unnecessary remove+reinsert.These are mostly transparent to callers.
If migrating from early 1.x, re-check Cargo.toml feature selection:
[dependencies]
starshard = { version = "2.2.0", features = ["async", "rayon", "serde", "lifecycle", "advanced"] }
2.2.x).try_with_*SnapshotMode::Cached / Cow for snapshot-heavy workloads.cargo test --all-features