mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 13:45:52 +03:00
[PR #829] [MERGED] Stream object downloads instead of buffering objects in memory #951
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#951
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fsouza/fake-gcs-server/pull/829
Author: @dnerdy
Created: 6/15/2022
Status: ✅ Merged
Merged: 9/2/2022
Merged by: @fsouza
Base:
main← Head:streaming-downloads📝 Commits (10+)
0cd6c3bStream object downloads instead of buffering object in memory1c2962eFix typo in xattr_windows.gof354f3dFix staticcheck lint errors.07f8045Attempt to fix renaming over open files on Windows1c9ecbbAdd build directive to rename_unix.god0e24d3Close objects when listing objects and in tests3d78ac9Use compatOpenForWritingAllowingRename for temp file227228fClose temp fileb15c8a5Move the Windows "temporary delete path" to the temp dir4f18d8dClose initial objects📊 Changes
19 files changed (+653 additions, -219 deletions)
View changed files
📝
fakestorage/object.go(+200 -75)📝
fakestorage/server.go(+2 -2)📝
fakestorage/server_test.go(+7 -4)📝
fakestorage/upload.go(+41 -41)📝
go.mod(+1 -0)📝
go.sum(+15 -0)📝
internal/backend/backend_test.go(+36 -13)📝
internal/backend/fs.go(+127 -47)📝
internal/backend/memory.go(+49 -22)📝
internal/backend/metadata.go(+1 -0)📝
internal/backend/metadata_file.go(+4 -0)📝
internal/backend/metadata_xattr.go(+4 -0)📝
internal/backend/object.go(+38 -0)➕
internal/backend/rename_unix.go(+21 -0)➕
internal/backend/rename_windows.go(+54 -0)📝
internal/backend/storage.go(+6 -6)📝
internal/checksum/checksum.go(+29 -0)📝
internal/notification/event.go(+5 -5)📝
internal/notification/event_test.go(+13 -4)📄 Description
Fixes #828.
This PR makes it so objects in the FS backend are streamed from disk
instead of being loaded into memory. This drastically reduces memory
usage when working with large files, especially when performing small
concurrent range reads on a large file.
A StreamingObject type has been added to both the fakestorage and
backend packages. This type contains a io.ReadSeekCloser that can be
used to access object data.
This change sets the stage for fixing #669 and #397. #669 isn't fixed
because it will require re-working of how resumable uploads are stored
(though other upload types have been made streaming in this PR). Also,
fixing #397 would require changing how initial objects are specified
when starting the server, which with this approach would require
changing the public API.
Regarding the public API: the server methods for working with objects
have been changed to use StreamingObject instead of Object. This is a
breaking change. It would be possible to make streaming backward
compatible by adding some metadata and methods to Object (to distinguish
between streaming and buffered objects), but I went with this approach
because it made identifying the code that needed to be updated easier;
the compiler pointed out the locations to update instead of needing to
track down runtime and test errors. An additional improvement, which is
compatible with the backward compatible approach, would be to add an
OpenForReading method on Object so callers that are currently
responsible for closing objects also explicitly open objects (which
would make the responsibility clearer). Anyway, I wanted to get this
initial approach up for feedback before putting in additional work.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.