"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: reduce memory usage by re-ordering commonly used structures
Nick Craig-Wooda07d376fb111
diff --git a/vfs/file.go b/vfs/file.goindex 2d3199f13..4431c6cc5 100644--- a/vfs/file.go+++ b/vfs/file.go@@ -39,19 +39,19 @@ type File struct {inode uint64 // inode number - read onlysize int64 // size of file - read and written with atomic int64 - must be 64 bit aligned+ muRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove+mu sync.RWMutex // protects the followingd *Dir // parent directorydPath string // path of parent directory. NB dir rename means all Files are flushedo fs.Object // NB o may be nil if file is being writtenleaf string // leaf name of the objectwriters []Handle // writers for this file- nwriters int32 // len(writers) which is read/updated with atomicpendingModTime time.Time // will be applied once o becomes available, i.e. after file was writtenpendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close- appendMode bool // file was opened with O_APPENDsys atomic.Value // user defined info to be attached here-- muRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove+ nwriters int32 // len(writers) which is read/updated with atomic+ appendMode bool // file was opened with O_APPEND}// newFile creates a new Filediff --git a/vfs/read.go b/vfs/read.goindex 4a5658ead..bfe4b2d5c 100644--- a/vfs/read.go+++ b/vfs/read.go@@ -21,18 +21,18 @@ type ReadFileHandle struct {done func(ctx context.Context, err error)mu sync.Mutexcond sync.Cond // cond lock for out of sequence reads- closed bool // set if handle has been closedr *accounting.Account- readCalled bool // set if read has been calledsize int64 // size of the object (0 for unknown length)offset int64 // offset of read of oroffset int64 // offset of Read() calls- noSeek bool- sizeUnknown bool // set if size of source is not knownfile *Filehash *hash.MultiHasher- opened boolremote string+ closed bool // set if handle has been closed+ readCalled bool // set if read has been called+ noSeek bool+ sizeUnknown bool // set if size of source is not known+ opened bool}// Check interfacesdiff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.goindex 883bc9bde..5d606f21e 100644--- a/vfs/vfscache/item.go+++ b/vfs/vfscache/item.go@@ -63,10 +63,10 @@ type Item struct {downloaders *downloaders.Downloaders // a record of the downloaders in action - may be nilo fs.Object // object we are caching - may be nilfd *os.File // handle we are using to read and write to the file- modified bool // set if the file has been modified since the last Openinfo Info // info about the file to persist to backing storewriteBackID writeback.Handle // id of any writebacks in progresspendingAccesses int // number of threads - cache reset not allowed if not zero+ modified bool // set if the file has been modified since the last OpenbeingReset bool // cache cleaner is resetting the cache file, access not allowed}diff --git a/vfs/write.go b/vfs/write.goindex 25fa4fbf6..4556ebe3e 100644--- a/vfs/write.go+++ b/vfs/write.go@@ -16,16 +16,16 @@ type WriteFileHandle struct {baseHandlemu sync.Mutexcond sync.Cond // cond lock for out of sequence writes- closed bool // set if handle has been closedremote stringpipeWriter *io.PipeWritero fs.Objectresult chan errorfile *File- writeCalled bool // set the first time Write() is calledoffset int64- opened boolflags int+ closed bool // set if handle has been closed+ writeCalled bool // set the first time Write() is called+ opened booltruncated bool}