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

use as many goroutines for ForgetInode op #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions fuseutil/file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ type FileSystem interface {
// requests").
func NewFileSystemServer(fs FileSystem) fuse.Server {
return &fileSystemServer{
fs: fs,
fs: fs,
opsForgetInode: make(chan int, 100000),
}
}

type fileSystemServer struct {
fs FileSystem
opsInFlight sync.WaitGroup
fs FileSystem
opsInFlight sync.WaitGroup
opsForgetInode chan int
}

func (s *fileSystemServer) ServeOps(c *fuse.Connection) {
Expand All @@ -113,11 +115,12 @@ func (s *fileSystemServer) ServeOps(c *fuse.Connection) {

s.opsInFlight.Add(1)
if _, ok := op.(*fuseops.ForgetInodeOp); ok {
// Special case: call in this goroutine for
// forget inode ops, which may come in a
// flurry from the kernel and are generally
// cheap for the file system to handle
s.handleOp(c, ctx, op)
// flurry from the kernel and we should
// to limit the number of goroutines
// one goroutine 2KB, 10w goroutine max 200MB
s.opsForgetInode <- 1
go s.handleOp(c, ctx, op)
} else {
go s.handleOp(c, ctx, op)
}
Expand Down Expand Up @@ -150,6 +153,7 @@ func (s *fileSystemServer) handleOp(

case *fuseops.ForgetInodeOp:
err = s.fs.ForgetInode(ctx, typed)
<-s.opsForgetInode

case *fuseops.MkDirOp:
err = s.fs.MkDir(ctx, typed)
Expand Down