Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/walrus-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ test-utils = ["walrus-test-utils"]
[dependencies]
base64.workspace = true
bcs.workspace = true
blake2 = "0.10.6"
digest = "0.10.7"
enum_dispatch = { workspace = true }
fastcrypto.workspace = true
hex.workspace = true
p256 = { workspace = true, features = ["pem", "pkcs8"] }
rand.workspace = true
rayon.workspace = true
reed-solomon-simd.workspace = true
serde.workspace = true
serde_with.workspace = true
Expand Down
14 changes: 6 additions & 8 deletions crates/walrus-core/benches/encoding_phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn primary_encoding_with_hashing(c: &mut Criterion) {
for (col_index, col) in columns.iter().enumerate() {
let symbols = enc.encode_all_ref(col).unwrap();
for (row_index, symbol) in symbols.to_symbols().enumerate() {
hashes[n_shards * row_index + col_index] =
hashes[col_index * n_shards + row_index] =
leaf_hash::<Blake2b256>(symbol);
}
}
Expand Down Expand Up @@ -188,15 +188,13 @@ fn metadata_from_hashes(c: &mut Criterion) {
// Build 2 * n_shards Merkle trees (primary + secondary per sliver pair).
for sliver_index in 0..n_shards {
let _primary = MerkleTree::<Blake2b256>::build_from_leaf_hashes(
hashes[n_shards * sliver_index..n_shards * (sliver_index + 1)]
.iter()
.cloned(),
(0..n_shards).map(|col| hashes[col * n_shards + sliver_index].clone()),
);
let sec_col = n_shards - 1 - sliver_index;
let _secondary = MerkleTree::<Blake2b256>::build_from_leaf_hashes(
(0..n_shards).map(|symbol_index| {
hashes[n_shards * symbol_index + n_shards - 1 - sliver_index]
.clone()
}),
hashes[sec_col * n_shards..(sec_col + 1) * n_shards]
.iter()
.cloned(),
);
}
});
Expand Down
23 changes: 19 additions & 4 deletions crates/walrus-core/examples/profile_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn get_peak_rss_bytes() -> usize {
unsafe {
let mut usage: libc::rusage = std::mem::zeroed();
libc::getrusage(libc::RUSAGE_SELF, &mut usage);
let max_rss = usage.ru_maxrss as usize;
let max_rss = usize::try_from(usage.ru_maxrss).unwrap();
// macOS reports bytes, Linux reports KB
if cfg!(target_os = "macos") {
max_rss
Expand All @@ -54,29 +54,44 @@ struct Args {
#[arg(long, default_value_t = 1)]
iterations: u32,

/// Number of rayon threads (0 = use rayon default, which is num CPUs)
#[arg(long, default_value_t = 0)]
threads: usize,

/// Number of blobs to encode concurrently (simulates multi-blob uploads)
#[arg(long, default_value_t = 1)]
concurrent_blobs: u32,
}

fn main() {
let args = Args::parse();

if args.threads > 0 {
rayon::ThreadPoolBuilder::new()
.num_threads(args.threads)
.build_global()
.unwrap();
}
let thread_count = rayon::current_num_threads();

let config = ReedSolomonEncodingConfig::new(NonZeroU16::new(args.shards).unwrap());

if args.concurrent_blobs > 1 {
print!(
"blob_size={} shards={} iterations={} concurrent_blobs={}",
"blob_size={} shards={} iterations={} threads={} concurrent_blobs={}",
format_size(args.size),
args.shards,
args.iterations,
thread_count,
args.concurrent_blobs
);
} else {
print!(
"blob_size={} shards={} iterations={}",
"blob_size={} shards={} iterations={} threads={}",
format_size(args.size),
args.shards,
args.iterations
args.iterations,
thread_count
);
}

Expand Down
Loading
Loading