mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
reduce memory usage
This commit is contained in:
parent
f224b9fe28
commit
2e6a3c7b16
|
@ -21,6 +21,8 @@ type MountOptions struct {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mountOptions MountOptions
|
mountOptions MountOptions
|
||||||
|
mountCpuProfile *string
|
||||||
|
mountMemProfile *string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -35,6 +37,8 @@ func init() {
|
||||||
mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
|
mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
|
||||||
mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 16, "local write buffer size, also chunk large files")
|
mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 16, "local write buffer size, also chunk large files")
|
||||||
mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
|
mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
|
||||||
|
mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
|
mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmdMount = &Command{
|
var cmdMount = &Command{
|
||||||
|
|
|
@ -28,6 +28,8 @@ func runMount(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
fuse.Unmount(*mountOptions.dir)
|
fuse.Unmount(*mountOptions.dir)
|
||||||
|
|
||||||
|
util.SetupProfiling(*mountCpuProfile, *mountMemProfile)
|
||||||
|
|
||||||
c, err := fuse.Mount(
|
c, err := fuse.Mount(
|
||||||
*mountOptions.dir,
|
*mountOptions.dir,
|
||||||
fuse.VolumeName("SeaweedFS"),
|
fuse.VolumeName("SeaweedFS"),
|
||||||
|
|
|
@ -28,6 +28,14 @@ func newDirtyPages(file *File) *ContinuousDirtyPages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pages *ContinuousDirtyPages) InitializeToFile(file *File) *ContinuousDirtyPages {
|
||||||
|
if len(pages.Data) != int(file.wfs.option.ChunkSizeLimit) {
|
||||||
|
pages.Data = make([]byte, file.wfs.option.ChunkSizeLimit)
|
||||||
|
}
|
||||||
|
pages.f = file
|
||||||
|
return pages
|
||||||
|
}
|
||||||
|
|
||||||
func (pages *ContinuousDirtyPages) AddPage(ctx context.Context, offset int64, data []byte) (chunks []*filer_pb.FileChunk, err error) {
|
func (pages *ContinuousDirtyPages) AddPage(ctx context.Context, offset int64, data []byte) (chunks []*filer_pb.FileChunk, err error) {
|
||||||
|
|
||||||
pages.lock.Lock()
|
pages.lock.Lock()
|
||||||
|
|
|
@ -37,6 +37,15 @@ func newFileHandle(file *File, uid, gid uint32) *FileHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fh *FileHandle) InitializeToFile(file *File, uid, gid uint32) *FileHandle {
|
||||||
|
newHandle := &FileHandle{
|
||||||
|
f: file,
|
||||||
|
dirtyPages: fh.dirtyPages.InitializeToFile(file),
|
||||||
|
Uid: uid,
|
||||||
|
Gid: gid,
|
||||||
|
}
|
||||||
|
return newHandle
|
||||||
|
}
|
||||||
var _ = fs.Handle(&FileHandle{})
|
var _ = fs.Handle(&FileHandle{})
|
||||||
|
|
||||||
// var _ = fs.HandleReadAller(&FileHandle{})
|
// var _ = fs.HandleReadAller(&FileHandle{})
|
||||||
|
|
|
@ -72,15 +72,14 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHand
|
||||||
return wfs.handles[index]
|
return wfs.handles[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
fileHandle = newFileHandle(file, uid, gid)
|
|
||||||
|
|
||||||
if found && wfs.handles[index] != nil {
|
if found && wfs.handles[index] != nil {
|
||||||
glog.V(4).Infoln(fullpath, "reuse previous fileHandle id", index)
|
glog.V(4).Infoln(fullpath, "reuse previous fileHandle id", index)
|
||||||
wfs.handles[index] = fileHandle
|
wfs.handles[index].InitializeToFile(file, uid, gid)
|
||||||
fileHandle.handle = uint64(index)
|
fileHandle.handle = uint64(index)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileHandle = newFileHandle(file, uid, gid)
|
||||||
for i, h := range wfs.handles {
|
for i, h := range wfs.handles {
|
||||||
if h == nil {
|
if h == nil {
|
||||||
wfs.handles[i] = fileHandle
|
wfs.handles[i] = fileHandle
|
||||||
|
|
Loading…
Reference in a new issue