Skip to content

Commit 3798040

Browse files
committed
Fixed again shrinking strategy; BvComp now uses Vec::shrink_to
1 parent d497765 commit 3798040

8 files changed

Lines changed: 24 additions & 10 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ members = ["algo", "cli", "webgraph"]
66
exclude = ["webgraph/fuzz"]
77

88
[workspace.dependencies]
9-
webgraph = { path = "./webgraph", version = "0.6.0" }
10-
webgraph-algo = { path = "./algo", version = "0.6.0" }
9+
webgraph = { path = "./webgraph", version = "0.6.1" }
10+
webgraph-algo = { path = "./algo", version = "0.6.1" }
1111
webgraph-cli = { path = "./cli" }
1212

1313
card-est-array = "0.2.1"

algo/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## [unreleased]
3+
## [0.6.1] - 2026-02-23
44

55
### New
66

algo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "webgraph-algo"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2024"
55
description = "Algorithms for the Rust port of the WebGraph framework (http://webgraph.di.unimi.it/)."
66
repository = "https://github.com/vigna/webgraph-rs/"

cli/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Change Log
22

3-
## [unreleased]
3+
## [0.4.1] - 2026-02-23
44

55
### New
66

77
- New `webgraph-rank` CLI supporting centrality measures.
88

9+
- Support for loading vectors parallel to previous support for writing vectors.
10+
911
### Improved
1012

1113
- Floats without a specified precision are now printed using the `zmij` crate,
1214
which brings a 3-4x speed improvement.
1315

16+
- We use the crate `zmij` for saving floats in ASCII when no precision is
17+
specified, which brings a 3-4x speed improvement.
18+
1419
## [0.4.0] - 2026-02-18
1520

1621
### New

webgraph/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## [0.6.1] - 2026-02-23
4+
5+
### Fixed
6+
7+
- The reallocation strategy of `BvCompZ` was plainly wrong, whereas that of
8+
`BvComp` was deallocating, reallocating and copying instead of using
9+
`Vec::shrink_to`.
10+
11+
- `BvGraphSeq` was sub-preallocating the successor vector (+1% speed).
12+
313
## [0.6.0] - 2026-02-18
414

515
### New

webgraph/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "webgraph"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2024"
55
description = "A Rust port of the WebGraph framework (http://webgraph.di.unimi.it/)."
66
repository = "https://github.com/vigna/webgraph-rs/"

webgraph/src/graphs/bvgraph/comp/bvcomp.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,8 @@ impl<E: EncodeAndEstimate, W: Write> BvComp<E, W> {
396396
let succ_vec = &mut self.backrefs[self.curr_node];
397397
succ_vec.clear();
398398
succ_vec.extend(succ_iter);
399-
if succ_vec.capacity() > 4 * succ_vec.len() {
400-
let old_vec = std::mem::replace(succ_vec, Vec::with_capacity(2 * succ_vec.len()));
401-
succ_vec.extend(old_vec);
399+
if succ_vec.len() < succ_vec.capacity() / 4 {
400+
succ_vec.shrink_to(succ_vec.capacity() / 2);
402401
}
403402
}
404403
// get the ref

webgraph/src/graphs/bvgraph/comp/bvcompz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<E: EncodeAndEstimate, W: Write> BvCompZ<E, W> {
485485
self.saved_costs.clear();
486486

487487
// Custom resizing logic
488-
if self.backrefs.num_values() < 4 * self.backrefs.values_capacity() {
488+
if self.backrefs.num_values() < self.backrefs.values_capacity() / 4 {
489489
self.backrefs
490490
.shrink_values_to(self.backrefs.values_capacity() / 2);
491491
}

0 commit comments

Comments
 (0)