From 9c23064839ba5021b199069364dc2001d25d1b0c Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 19 Mar 2024 07:36:25 -0400 Subject: [PATCH] Controllable preallocation --- polbin/src/file.rs | 18 +++++++++--------- polbin/src/main.rs | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/polbin/src/file.rs b/polbin/src/file.rs index 68c5a2a0..07b8023a 100644 --- a/polbin/src/file.rs +++ b/polbin/src/file.rs @@ -116,16 +116,16 @@ impl Toc { Self { magic: MAGIC_NUMBER, header: Size::empty(128), - segs: Size::empty(512 * factor), - paths: Size::empty(16 * factor), - links: Size::empty(1024 * factor), - steps: Size::empty(512 * factor), - seq_data: Size::empty(4096 * factor), - overlaps: Size::empty(512 * factor), - alignment: Size::empty(1024 * factor), + segs: Size::empty(32 * factor * factor), + paths: Size::empty(factor), + links: Size::empty(32 * factor * factor), + steps: Size::empty(1024 * factor * factor), + seq_data: Size::empty(512 * factor * factor), + overlaps: Size::empty(256 * factor), + alignment: Size::empty(64 * factor * factor), name_data: Size::empty(64 * factor), - optional_data: Size::empty(64 * factor), - line_order: Size::empty(2048 * factor), + optional_data: Size::empty(512 * factor * factor), + line_order: Size::empty(64 * factor * factor), } } } diff --git a/polbin/src/main.rs b/polbin/src/main.rs index 6a4463a1..d14f182b 100644 --- a/polbin/src/main.rs +++ b/polbin/src/main.rs @@ -65,6 +65,10 @@ struct PolBin { /// print statistics about the graph #[argh(switch, short = 's')] stats: bool, + + /// preallocation size factor + #[argh(option, short = 'p', default = "32")] + prealloc_factor: usize, } fn main() { @@ -74,7 +78,7 @@ fn main() { if args.mutate { if let (None, Some(out_name)) = (&args.input, &args.output) { // Create a file with an empty table of contents. - let empty_toc = file::Toc::guess(5); + let empty_toc = file::Toc::guess(args.prealloc_factor); let mut mmap = map_new_file(out_name, empty_toc.size() as u64); let (toc, store) = file::init(&mut mmap, empty_toc);