Fix the capacity of poolable#1
Merged
dignifiedquire merged 2 commits intoasync-email:masterfrom Jul 29, 2020
Merged
Conversation
A vector can allocate more space than the current number of elements, this allows it to cheaply grow the elements. This is what vec.capacity() returns. vec.len() returns the actual number of items in use, this is also the number of items you will get when slicing with e.g. vec[..]. This latter matters since this is how the block is meant to be used: a lot of consumers silce the block. Hence vec.len() gives the actual capacity of the block. This is also reflected with how the block (re)allocates capacity: vec.resize() changes the Vec's len with no guarantees how it affects the Vec capacity.
Collaborator
|
Maybe add this explanation to the code comment too? |
Member
|
can you update the |
It seems the hashmap capacity is, similarly to Vec, not exactly controllable and we can not always guarantee len == capacity. Again similarly when Block::size() returns a given lenght you expect to be able to index to this length.
dignifiedquire
approved these changes
Jul 29, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've tested this with the test suites of async-h1, async-imap, deltachat-rust-core and with my imapsyncer tool. With this fix the latter is able to reliably download and synchronise 260k emails, without this fix the stream always gets stuck* at some point.
commit message:
A vector can allocate more space than the current number of elements,
this allows it to cheaply grow the elements. This is what
vec.capacity() returns. vec.len() returns the actual number of items
in use, this is also the number of items you will get when slicing
with e.g. vec[..]. This latter matters since this is how the block is
meant to be used: a lot of consumers silce the block. Hence vec.len()
gives the actual capacity of the block. This is also reflected with
how the block (re)allocates capacity: vec.resize() changes the Vec's
len with no guarantees how it affects the Vec capacity.