-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
✨ Read files content lazily [joelanford edits] #16
✨ Read files content lazily [joelanford edits] #16
Conversation
6fe7bc4
to
dd82e53
Compare
Added another commit, which simplifies code further and seems to make some small gains in the benchmark:
|
Hi @joelanford |
I've had the time to read this, it's awesome! Is it OK with you if I merge your commits in the upstream PR, and then add some tests and perform some minor refactorings? |
Thanks! Yeah go for it. And feel free to squash my commits down, rewrite messages, or whatever make sense and is to your liking! |
0c608b0
to
407e63e
Compare
use the offset to avoid iterating tar file when opening each file. Signed-off-by: Joe Lanford <[email protected]>
after we've read the non-readerAt reader into a buffer, we now have a readerAt either way, which simplifies code and no longer requires separate buffers per file entry. Signed-off-by: Joe Lanford <[email protected]>
Reading file content straight from the underlying reader was too straightforward. Instead read from a new tar.Reader with an underlying reader pointing straight to the tar entry we want to read.
Should improve initial read of the tar file.
407e63e
to
4470b8a
Compare
dd82e53
to
e2b14b7
Compare
d40ec9e
to
2b152d0
Compare
Updated before and after benchmarks: Before:
After:
Note the new |
2b152d0
to
9bd4928
Compare
Signed-off-by: Joe Lanford <[email protected]>
9bd4928
to
31be8d2
Compare
fs.go
Outdated
func DisableSeek(disable bool) func(*options) { | ||
return func(o *options) { | ||
o.disableSeek = disable | ||
} | ||
} |
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 sorta feel like non-seekable files should be the default because it is more performant, but that would be a breaking change for anyone using the library with http.FS
.
Since this library is at v1, I decided to make this a non-breaking change, which means callers would have to specifically opt in to the more performant behavior if they have no need to seek. But maybe it is worth considering bumping to v2?
30ec627
to
2aa91f4
Compare
Based somewhat on #15 (comment), this extra commit is what I was thinking.
Benchmarks before:
Benchmarks after: