Skip to content
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

[performance] update storage backend and make use of seek syscall when available #2924

Conversation

NyaaaWhatsUpDoc
Copy link
Member

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc commented May 21, 2024

Description

This moves us from using codeberg.org/gruf/go-store/v2/storage using codeberg.org/gruf/go-storage as our underlying storage library. Which itself is just moving the library out of the nested repo it was in, since it expanded in usage scope from its original use. This in turn trims some of the unused dependencies from the vendor/ folder, and makes it easier updating the go-storage library myself since i don't need to update the rest of the key-value store around it. (also the key-value store itself isn't really getting used anymore by any of my projects, so it may end up falling by the wayside, and that's fine)

In updating to this version of the underlying storage library, since there's no more wrapping of the returned reader types, we can now rely on the seek syscall in a number of places which should speed-up file serving and video decoding on those using disk based storage :)

Checklist

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@@ -80,10 +80,6 @@ func setupPrune(ctx context.Context) (*prune, error) {
func (p *prune) shutdown() error {
errs := gtserror.NewMultiError(2)

if err := p.storage.Close(); err != nil {
Copy link
Member Author

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new storage type doesn't bother with any kind of close mechanism as it's not really needed

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc changed the title [chore] move to separate go storage library [performance] update storage backend and make use of seek syscall when available May 21, 2024
if _, err := fastcopy.CopyN(io.Discard, src, start); err != nil {
log.Errorf(r.Context(), "error reading from source: %v", err)
return
if rs, ok := src.(io.ReadSeeker); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

@tsmethurst tsmethurst merged commit 3d3e99a into superseriousbusiness:main May 22, 2024
2 checks passed
@tsmethurst
Copy link
Contributor

Good one!

NyaaaWhatsUpDoc added a commit to NyaaaWhatsUpDoc/gotosocial that referenced this pull request Jun 7, 2024
…n available (superseriousbusiness#2924)

* update to use go-storage/ instead of go-store/v2/storage/

* pull in latest version from codeberg

* remove test output 😇

* add code comments

* set the exclusive bit when creating new files in disk config

* bump to actual release version

* bump to v0.1.1 (tis a simple no-logic change)

* update readme

* only use a temporary read seeker when decoding video if required (should only be S3 now)

* use fastcopy library to use memory pooled buffers when calling TempFileSeeker()

* update to use seek call in serveFileRange()
nyarla pushed a commit to nyarla/gotosocial-modded that referenced this pull request Jun 19, 2024
…n available (superseriousbusiness#2924)

* update to use go-storage/ instead of go-store/v2/storage/

* pull in latest version from codeberg

* remove test output 😇

* add code comments

* set the exclusive bit when creating new files in disk config

* bump to actual release version

* bump to v0.1.1 (tis a simple no-logic change)

* update readme

* only use a temporary read seeker when decoding video if required (should only be S3 now)

* use fastcopy library to use memory pooled buffers when calling TempFileSeeker()

* update to use seek call in serveFileRange()
nyarla pushed a commit to nyarla/gotosocial-modded that referenced this pull request Jun 19, 2024
…n available (superseriousbusiness#2924)

* update to use go-storage/ instead of go-store/v2/storage/

* pull in latest version from codeberg

* remove test output 😇

* add code comments

* set the exclusive bit when creating new files in disk config

* bump to actual release version

* bump to v0.1.1 (tis a simple no-logic change)

* update readme

* only use a temporary read seeker when decoding video if required (should only be S3 now)

* use fastcopy library to use memory pooled buffers when calling TempFileSeeker()

* update to use seek call in serveFileRange()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants