1.0.0 to 1.2.x2.0.0 to 2.4.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.
Existing CRUD and Entry signatures remain available. New APIs include shared_snapshot(), get_borrowed, contains_borrowed, remove_borrowed, and read_with.
versioned_snapshot() and snapshot_at_version() use the committed data epoch. Repeated snapshots without writes have the same version; query the returned version directly, without adding one. Historical versions are not retained, and epochs are not operation counters.Cached and Cow share a lazy whole-map cache. Valid hits bypass routing; rebuilds use a dedicated builder gate and ordered shard read locks. Ordinary reads can proceed subject to lock fairness, while writers and topology changes may wait. Use shared handles to avoid owned-output copies.replica_count and write_quorum: two remote replicas plus one primary use QuorumConfig::strict(3) or majority(3). Prefer try_with_replication for recoverable validation; with_replication panics on invalid topology or configuration.lock_profiles() returns no samples until real instrumentation exists. TTL/eviction configuration and standalone metrics do not enable an autonomous scheduler.Run the feature combinations you deploy and remeasure workload-specific latency, throughput, and memory. Allocation/hash reductions are not a universal throughput or p99 guarantee.
If migrating from early 1.x, re-check Cargo.toml feature selection:
[dependencies]
starshard = { version = "2.4.0", features = ["async", "rayon", "serde", "lifecycle", "advanced"] }
2.4.x).try_with_*SnapshotMode::Cached / Cow for snapshot-heavy workloads.cargo test --all-features