Skip to content

Commit

Permalink
Controllable preallocation
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Mar 19, 2024
1 parent b7b6d13 commit 9c23064
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 9 additions & 9 deletions polbin/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion polbin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);

Expand Down

0 comments on commit 9c23064

Please sign in to comment.