-
Notifications
You must be signed in to change notification settings - Fork 81
core: Reduce amount of calls to getattr/Stat, improve vfs.read #157
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
Conversation
|
Are there any benchmarks that justify this change? Almost all operations are subject to permission checks, thus, file attributes are almost always required. To reduce the number of filesystem calls, we use VfsCache which aggressively caches getattrs. |
|
The file type can (in many cases) be encoded directly in the Inode file handle, which means that the lookup is free. Caching can only go so far, especially when the file can be modified outside of nfs4j. |
|
fwiw, I'm working on a bigger change that improves read/write performance by 20%, and it's based on this code. |
|
Hi @kohlschuetter , I definitely don't want to see a getXxx Method per attribute type. However, I can see the use case. Thus, I suggest updating the getattr method to accept an enum set of desired StatAttribute, similar to statx function and GETATTR operation. The file system implementations can optimize and return only those or more. The Stat class is already designed to return only a subset of the attributes. |
|
Yes, that's certainly doable. The thing I'm concerned about is that in However, When we check "is it a file or directory", we're really only interested in the immutable part. That information, once encoded in a trusted file handle, can be guaranteed to not change. The mutable access rights part however can change any minute, so we have to make a file system hit for that. Since we currently cannot distinguish between "I want the type" vs "I want the mode", we still need that differentiating method (hence my explanation in the Javadoc for getStatType). If we use an If we go that route, then it's best to introduce a I'll look into that. |
For many operations, we currently call VirtualFileSystem#getattr(Inode), which gets a full set of "stat" metadata for a given Inode. In many cases however, we're only interested in the type of the Inode (e.g., directory, regular file, symlink, etc.). Certain VirtualFileSystem implementations may be able to retrieve that specific information significantly faster than the full metadata set. Replace calls to vfs.getattr(Inode).type() with vfs.getStatType() where applicable, and provide default implementations for backwards compatibility. Also don't retrieve Stat information at all where not required: 1. In PseudoFS.checkAccess with ACE4_READ_ATTRIBUTES, and 2. For OperationREAD, allow VirtualFileSystem to skip the Stat check (currently checking StatType but also file size), which is currently done per every call to "read": Clarify the requirement of signaling "eof reached" as per NFSv4 spec, provide a new read() method to VirtualFileSystem with a corresponding callback function, and provide a default implementation for backwards compatibility. Signed-off-by: Christian Kohlschütter <[email protected]>
Signed-off-by: Christian Kohlschütter <[email protected]>
As per request, let's handle getting the Stat type not as a special case but via a generalizable getattr method that takes an EnumSet of StatAttributes. Signed-off-by: Christian Kohlschütter <[email protected]>
|
OK, I hope this works for you now. We don't need a new PS: I see that on Linux, statx has that TYPE-only option too, so |
For many operations, we currently call VirtualFileSystem#getattr(Inode), which gets a full set of "stat" metadata for a given Inode.
In many cases however, we're only interested in the type of the Inode (e.g., directory, regular file, symlink, etc.). Certain VirtualFileSystem implementations may be able to retrieve that specific information significantly faster than the full metadata set.
Replace calls to vfs.getattr(Inode).type() with vfs.getStatType() where applicable, and provide default implementations for backwards compatibility.
Also don't retrieve Stat information at all where not required:
In PseudoFS.checkAccess with ACE4_READ_ATTRIBUTES, and
For OperationREAD, allow VirtualFileSystem to skip the Stat check (currently checking StatType but also file size), which is currently done per every call to "read":
Clarify the requirement of signaling "eof reached" as per NFSv4 spec, provide a new read() method to VirtualFileSystem with a corresponding callback function, and provide a default implementation for backwards compatibility.