-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Use streaming file reads when comparing for writes #4093
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
9 Ignored Deployments
|
🟢 CI successful 🟢Thanks |
Benchmark for 6fd5d29
Click to view full benchmark
|
crates/turbo-tasks-fs/src/util.rs
Outdated
/// continue to be returned until the full buffer has been consumed. This allows | ||
/// us to skip the overhead of, eg, repeated sys calls to read from disk as we | ||
/// process a smaller number of bytes. | ||
pub struct AsyncBufReader<'a, T: AsyncRead + Unpin + Sized> { |
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.
What's the difference to https://docs.rs/tokio/latest/tokio/io/struct.BufReader.html?
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.
😳 I searched the docs for AsyncBufReader
and not BufReader
, and implemented this from scratch because I didn't find anything.
crates/turbo-tasks-fs/src/lib.rs
Outdated
// So meta matches, and we have a file handle. Let's stream the contents to see | ||
// if they match. | ||
let mut new_contents = new_file.read(); | ||
let mut old_contents = AsyncBufReader::new(&mut old_file); |
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.
Performance-wise it would probably be better to avoid the buffered reader here and just read directly from the old_file as much as possible. Probably requires a little bit more complicated compare logic to handle consumed positions.
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.
I think you're assuming reading from a file returns a buffer, and we're then copying from that buffer into our BufReader
buffer. But that's not the case, the read()
API requires you to maintain a buffer and that gets passed to the system to copy bytes into, reading doesn't return a system buffer.
So we can either maintain our own buffer in this loop, or we can reuse the buffer created as part of 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.
I see 👍
Benchmark for fbf69aa
Click to view full benchmark
|
43e62c7
to
36b5d76
Compare
Benchmark for b22cce7
Click to view full benchmark
|
fbc152f
to
36b5d76
Compare
Benchmark for 8228312
Click to view full benchmark
|
Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
Benchmark for 604a028
Click to view full benchmark
|
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
# New Features - vercel/turborepo#3975 # Bug Fixes - vercel/turborepo#4129 - vercel/turborepo#4134 - vercel/turborepo#4062 # Performance - vercel/turborepo#4093
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
### Description Following vercel#3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
…4093) ### Description Following #3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
…4093) ### Description Following #3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
…4093) ### Description Following #3526, this reimplements `write(content)`'s file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write. ### Testing Instructions Wait for benchmarks. --------- Co-authored-by: Alex Kirszenberg <[email protected]>
Description
Following #3526, this reimplements
write(content)
's file comparison to stream the contents of the file. Not every file we write is massive, but some of the ones we generate are 100kb+. I hope this can reduce memory pressure a bit by using a consistent 8kb block size, instead of allocating a buffer for the full file contents just to check if we should write.Testing Instructions
Wait for benchmarks.