Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce memory consumption in wavelet matrix builder #45

Merged
merged 3 commits into from
Nov 23, 2022

Conversation

kampersanda
Copy link
Owner

@kampersanda kampersanda commented Nov 23, 2022

This PR uses CompactVector instead of Vec for buffers in WaveletMatrixBuilder, allowing us to specify the minimum number of bits to store an input integer for working memory efficiency.

I measured the peak resident set size during constructing WaveletMatrix from $2^{26}$ random bytes (code is here).

# v0.5.0
$ /usr/bin/time ../target/release/wmb
[bench/src/wmb.rs:16] wm.len() = 67108864
4.09user 0.41system 0:04.52elapsed 99%CPU (0avgtext+0avgdata 1152920maxresident)k
0inputs+0outputs (0major+35199minor)pagefaults 0swaps

# New version (will be v0.6.0)
$ /usr/bin/time ../target/release/wmb
[bench/src/wmb.rs:17] wm.len() = 67108864
5.83user 0.10system 0:05.93elapsed 99%CPU (0avgtext+0avgdata 244280maxresident)k
0inputs+0outputs (0major+68665minor)pagefaults 0swaps

The working memory was reduced from 1.1 GB to 0.24 GB, although the speed was slower.

In this PR, I removed the function WaveletMatrix::from_ints() because this can lead to a memory inefficient construction way.

@kampersanda kampersanda linked an issue Nov 23, 2022 that may be closed by this pull request
Copy link
Collaborator

@hirosassa hirosassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool PR! Looks good.

I removed the function WaveletMatrix::from_ints() because this can lead to a memory inefficient construction way.

I agree with your idea. Your newer implementation provides simple API for users.

@kampersanda kampersanda merged commit b557c52 into main Nov 23, 2022
@kampersanda kampersanda deleted the reduce-memory-in-wavelet-builder branch November 23, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

high peak memory consumption of WaveletMatrix::from_ints
2 participants