summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-store
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-03-08 11:56:53 +0000
committerLibravatar GitHub <noreply@github.com>2022-03-08 12:56:53 +0100
commitb8879ac68a30e8bccd1c96cc4630da791d8996c4 (patch)
tree77adeeaf2456610b771d9df8dc38207014215aea /vendor/codeberg.org/gruf/go-store
parent[performance] Database optimizations (#419) (diff)
downloadgotosocial-b8879ac68a30e8bccd1c96cc4630da791d8996c4.tar.xz
[dependencies] update go-store, go-mutexes (#422)
* update go-store, go-mutexes Signed-off-by: kim <grufwub@gmail.com> * update vendored code Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-store')
-rw-r--r--vendor/codeberg.org/gruf/go-store/kv/store.go2
-rw-r--r--vendor/codeberg.org/gruf/go-store/storage/disk.go31
2 files changed, 16 insertions, 17 deletions
diff --git a/vendor/codeberg.org/gruf/go-store/kv/store.go b/vendor/codeberg.org/gruf/go-store/kv/store.go
index a8741afe0..fd9935f25 100644
--- a/vendor/codeberg.org/gruf/go-store/kv/store.go
+++ b/vendor/codeberg.org/gruf/go-store/kv/store.go
@@ -45,7 +45,7 @@ func OpenStorage(storage storage.Storage) (*KVStore, error) {
// Return new KVStore
return &KVStore{
- mutex: mutexes.NewMap(-1),
+ mutex: mutexes.NewMap(-1, -1),
storage: storage,
}, nil
}
diff --git a/vendor/codeberg.org/gruf/go-store/storage/disk.go b/vendor/codeberg.org/gruf/go-store/storage/disk.go
index 287042886..b3c480b3d 100644
--- a/vendor/codeberg.org/gruf/go-store/storage/disk.go
+++ b/vendor/codeberg.org/gruf/go-store/storage/disk.go
@@ -10,7 +10,7 @@ import (
"syscall"
"codeberg.org/gruf/go-bytes"
- "codeberg.org/gruf/go-pools"
+ "codeberg.org/gruf/go-fastcopy"
"codeberg.org/gruf/go-store/util"
)
@@ -81,10 +81,10 @@ func getDiskConfig(cfg *DiskConfig) DiskConfig {
// DiskStorage is a Storage implementation that stores directly to a filesystem
type DiskStorage struct {
- path string // path is the root path of this store
- bufp pools.BufferPool // bufp is the buffer pool for this DiskStorage
- config DiskConfig // cfg is the supplied configuration for this store
- lock *Lock // lock is the opened lockfile for this storage instance
+ path string // path is the root path of this store
+ cppool fastcopy.CopyPool // cppool is the prepared io copier with buffer pool
+ config DiskConfig // cfg is the supplied configuration for this store
+ lock *Lock // lock is the opened lockfile for this storage instance
}
// OpenFile opens a DiskStorage instance for given folder path and configuration
@@ -147,13 +147,17 @@ func OpenFile(path string, cfg *DiskConfig) (*DiskStorage, error) {
return nil, err
}
- // Return new DiskStorage
- return &DiskStorage{
+ // Prepare DiskStorage
+ st := &DiskStorage{
path: storePath,
- bufp: pools.NewBufferPool(config.WriteBufSize),
config: config,
lock: lock,
- }, nil
+ }
+
+ // Set copypool buffer size
+ st.cppool.Buffer(config.WriteBufSize)
+
+ return st, nil
}
// Clean implements Storage.Clean()
@@ -271,13 +275,8 @@ func (st *DiskStorage) WriteStream(key string, r io.Reader) error {
}
defer cFile.Close()
- // Acquire write buffer
- buf := st.bufp.Get()
- defer st.bufp.Put(buf)
- buf.Grow(st.config.WriteBufSize)
-
- // Copy reader to file
- _, err = io.CopyBuffer(cFile, r, buf.B)
+ // Copy provided reader to file
+ _, err = st.cppool.Copy(cFile, r)
return err
}