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

Archiving optimizations #224

Merged
merged 4 commits into from
Jan 3, 2022
Merged

Archiving optimizations #224

merged 4 commits into from
Jan 3, 2022

Conversation

nazar-pc
Copy link
Member

The amount of memory copying and allocations in archiving bothered me for a while and I decided to finally optimize it.

The result is ~3% improvement on added benchmark. I didn't know what to expect, but I'm happy that there is an improvement.

I also enabled optimizations for some crates so I don't have to compile everything in debug mode for erasure coding to not take forever.

@nazar-pc nazar-pc force-pushed the archiving-optimizations branch from b82b4fc to 77a8246 Compare December 31, 2021 20:22
@@ -274,13 +272,27 @@ impl FlatPieces {
pub fn into_inner(self) -> Vec<u8> {
self.0
}

/// Iterator over individual pieces as byte slices.
pub fn as_pieces(&self) -> impl ExactSizeIterator<Item = &[u8]> {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a bunch of pieces.as_pieces() which just sounds like pieces as pieces, perhaps better to use flat_pieces.as_pieces in these cases. Just a thought, feel free to ignore it.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are a few places where it can be done, but I don't think it can be done everywhere while making perfect sense. Let's keep this in mind and maybe refactor in the future.

Copy link
Contributor

@liuchengxu liuchengxu left a comment

Choose a reason for hiding this comment

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

LGTM.

@nazar-pc nazar-pc merged commit 35cf6f5 into main Jan 3, 2022
@nazar-pc nazar-pc deleted the archiving-optimizations branch January 3, 2022 14:41
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.

2 participants