mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
vfs: reduce memory usage by re-ordering commonly used structures
This commit is contained in:
parent
e749bc58f4
commit
a07d376fb1
@ -39,19 +39,19 @@ type File struct {
|
||||
inode uint64 // inode number - read only
|
||||
size 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 following
|
||||
d *Dir // parent directory
|
||||
dPath string // path of parent directory. NB dir rename means all Files are flushed
|
||||
o fs.Object // NB o may be nil if file is being written
|
||||
leaf string // leaf name of the object
|
||||
writers []Handle // writers for this file
|
||||
nwriters int32 // len(writers) which is read/updated with atomic
|
||||
pendingModTime time.Time // will be applied once o becomes available, i.e. after file was written
|
||||
pendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close
|
||||
appendMode bool // file was opened with O_APPEND
|
||||
sys 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 File
|
||||
|
10
vfs/read.go
10
vfs/read.go
@ -21,18 +21,18 @@ type ReadFileHandle struct {
|
||||
done func(ctx context.Context, err error)
|
||||
mu sync.Mutex
|
||||
cond sync.Cond // cond lock for out of sequence reads
|
||||
closed bool // set if handle has been closed
|
||||
r *accounting.Account
|
||||
readCalled bool // set if read has been called
|
||||
size int64 // size of the object (0 for unknown length)
|
||||
offset int64 // offset of read of o
|
||||
roffset int64 // offset of Read() calls
|
||||
noSeek bool
|
||||
sizeUnknown bool // set if size of source is not known
|
||||
file *File
|
||||
hash *hash.MultiHasher
|
||||
opened bool
|
||||
remote 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 interfaces
|
||||
|
@ -63,10 +63,10 @@ type Item struct {
|
||||
downloaders *downloaders.Downloaders // a record of the downloaders in action - may be nil
|
||||
o fs.Object // object we are caching - may be nil
|
||||
fd *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 Open
|
||||
info Info // info about the file to persist to backing store
|
||||
writeBackID writeback.Handle // id of any writebacks in progress
|
||||
pendingAccesses int // number of threads - cache reset not allowed if not zero
|
||||
modified bool // set if the file has been modified since the last Open
|
||||
beingReset bool // cache cleaner is resetting the cache file, access not allowed
|
||||
}
|
||||
|
||||
|
@ -16,16 +16,16 @@ type WriteFileHandle struct {
|
||||
baseHandle
|
||||
mu sync.Mutex
|
||||
cond sync.Cond // cond lock for out of sequence writes
|
||||
closed bool // set if handle has been closed
|
||||
remote string
|
||||
pipeWriter *io.PipeWriter
|
||||
o fs.Object
|
||||
result chan error
|
||||
file *File
|
||||
writeCalled bool // set the first time Write() is called
|
||||
offset int64
|
||||
opened bool
|
||||
flags int
|
||||
closed bool // set if handle has been closed
|
||||
writeCalled bool // set the first time Write() is called
|
||||
opened bool
|
||||
truncated bool
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user