-
Notifications
You must be signed in to change notification settings - Fork 210
use BufReader to read archive index files #1530
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
Conversation
What was it before this change?
👍 |
src/storage/archive_index.rs
Outdated
@@ -28,11 +28,14 @@ pub(crate) struct Index { | |||
|
|||
impl Index { | |||
pub(crate) fn load(reader: impl io::Read) -> Result<Index> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we take BufReader
here instead, to avoid having a BufReader<BufReader>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while changing this I saw an issue with that:
sometimes we are using load
with a slice. In this case I also used an unnecessary BufReader
.
Also, the BufWriter
on save
doesn't help, because we're saving into a in-memory buffer anyways...
I updated the code, even less now
roughly the same ratio, so over 20 seconds |
f2d80f8
to
8c76fa2
Compare
fcbac39
to
c8a1f35
Compare
c8a1f35
to
c4cbe31
Compare
I ran test with an index with 17k files:
Since the average archive-size for docs is just around 600 I think we should merge and deploy this first.
Using mmap made it only slightly faster, which is why I didn't add the additional dependency.
The next optimization is probably not to load the whole index into memory but to answer the find-file requests while streaming the content of the index. But I would like to gather more data on archive-sizes first and benchmark it.