-
Notifications
You must be signed in to change notification settings - Fork 67
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
Various performance fixes #115
Conversation
eryugey
commented
Apr 14, 2023
- convert generic MultikeyBTreeMap to a app-specific InodeStore
- optimize virtio transport to avoid expending VecDeque
- add config to control mnt id in InodeAltKey
- add config to specify dir-entry-timeout and dir-attr-timeout
- remove some trace logs in hot paths
In commit 095d821 ("passthrough: add mnt id as inode alt key") we added mntid as part of inode alt key, and use name_to_handle_at(2) to get mntid. And recent perf tests show that name_to_handle_at(2) is kind of expensive in lookup intensive workloads. So add a knob to control it, and default to false. Signed-off-by: Eryu Guan <[email protected]>
For AI training workloads, APP reads large number of files from dataset and only reads them once. So entry and attr cache for such files are not needed, and large number of cached entry will make InodeMap bigger and bigger, and make InodeMap re-allocate its memory over and over again, which hits performance. On the other hand, the entry cache for dir is very helpful. But entry_timeout and attr_timeout will set the same timeout value for both dirs and regular files. So introduce 'dir_entry_timeout' and 'dir_attr_timeout' config options to config dir entry/attr separately. So that we could use cache=none (which indicates entry/attr timeout as 0 and bypass guest pagecache to avoid massive memory copy) and set dir_entry_timeout and dir_attr_timeout as none-zero to cache dirs. Signed-off-by: Eryu Guan <[email protected]>
The implementation of MultiKeyBTreeMap is for generic usage and may not be efficient in passthroughfs, e.g. it has a vector in alt key and when InodeMap grows, it triggers many memory re-allocations, and hits performance. So introduce application-specific InodeStore struct to replace the generic MultiKeyBTreeMap. This follows virtiofsd-rs commit 4d27d3ec772f ("passthrough: Use application-specific inode storage") Signed-off-by: Eryu Guan <[email protected]>
lookup() and forget() are two hot paths, we see performance hit even if trace log is not enabled. So remove trace log in hot paths. Signed-off-by: Eryu Guan <[email protected]>
Expending VecDeque might be expensive, so pre-allocating a vecDeque with a fixed 64 capacity and hope it could hold all slices we need. And it will expand if it's not big enough anyway. Signed-off-by: Eryu Guan <[email protected]>
Signed-off-by: Eryu Guan <[email protected]>
.unwrap(); | ||
// Allocate VecDeque with 64 capacity and hope it could hold all slices to avoid expending | ||
// VecDeque repeatedly. | ||
let mut buffers = VecDeque::with_capacity(64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can just stop at some point instead of grouping all the readable descriptors every time a chain is accessed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge as is and look for more optimization in future.