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

handle forget inline instead of in goroutine #30

Merged
merged 1 commit into from
Oct 10, 2017

Conversation

kahing
Copy link
Contributor

@kahing kahing commented Oct 6, 2017

when we are under memory pressure, or echo 3 > /proc/sys/vm/drop_caches,
kernel can send us many forget ops at the same time if we have lots of
inodes in memory. Running them all in goroutines can lead to even more
memory usage and eventually OOM.

@kahing kahing mentioned this pull request Oct 6, 2017
@jacobsa
Copy link
Owner

jacobsa commented Oct 9, 2017

There are some potential performance and deadlock issues that I'm trying to
think through here:

  • fileSystemServer.handleOp calls into Connection.Reply, which eventually writes the response to the kernel if kernelResponse returns false. Fortunately it returns true for ForgetInodeOp. So we don't have to worry about a deadlock where the kernel waits to consume the response until we've pulled more off the incoming queue, but we're blocking on writing the response. So I think this is okay.

  • The only other substantive thing that handleOp does is call FileSystem.ForgetInode. I worry that it may be an issue if this blocks on some other op coming in. But I can't think of any case where that would be reasonable, and indeed in the gcsfuse implementation at least the function wouldn't behave any different with a synchronous call.

So I'm happy with this overall. Could you please make a few changes though?

  1. Add comments in the code you've changed that say why you're calling synchronously in this case. Something like "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."

  2. Fix the comment on NewFileSystemServer that's no longer true. Document that ForgetInode may be called synchronously, and should not depend on calls to other methods being received concurrently.

when we are under memory pressure, or echo 3 > /proc/sys/vm/drop_caches,
kernel can send us many forget ops at the same time if we have lots of
inodes in memory. Running them all in goroutines can lead to even more
memory usage and eventually OOM.
@kahing
Copy link
Contributor Author

kahing commented Oct 10, 2017

amended commit with comments

@jacobsa
Copy link
Owner

jacobsa commented Oct 10, 2017

Thanks!

@jacobsa jacobsa merged commit 1ab97fb into jacobsa:master Oct 10, 2017
kahing added a commit to kahing/catfs that referenced this pull request Jan 3, 2018
@zhjunqin
Copy link

zhjunqin commented Jan 7, 2019

@kahing

I'm not sure my issue has anything to do with this or not.

Could you help check #60 ?

Thanks a lot!

kungf added a commit to kungf/fuse that referenced this pull request Mar 17, 2020
in jacobsa#30 forgetinode was changed into inline ServerOps, this may solove
memory oom, but the performance of rm op will be very slow, and it will
also hang other ops, so i think add a goroutine pool to limit the max
num of forgetinode goroutines, but not affect the performance
kungf added a commit to kungf/fuse that referenced this pull request Mar 18, 2020
in jacobsa#30 forgetinode was changed into inline ServerOps, this may solove
memory oom, but the performance of rm op will be very slow, and it will
also hang other ops, so i think limit the max num of forgetinode
goroutines, this can avoid oom but not affect performance
kungf added a commit to kungf/fuse that referenced this pull request Mar 18, 2020
in jacobsa#30 forgetinode was changed into inline ServerOps, this may solove
memory oom, but the performance of rm op will be very slow, and it will
also hang other ops, so i think limit the max num of forgetinode
goroutines, this can avoid oom but not affect performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants