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

qemu_nbd: Select cache and aio automatically #42

Merged
merged 1 commit into from
Mar 13, 2022
Merged

Conversation

nirs
Copy link
Member

@nirs nirs commented Mar 13, 2022

Previously we use --cache=writeback and --aio=threads so we can access
images on file system that does not support direct I/O. This is
sometimes faster than --cache=none and --aio=native, but typically give
less consistent results, and pollute the page cache with image data,
which is mostly likely will never be used.

When uploading and downloading images on a hypervisor, using the page
cache can be harmful and cause sanlock timeouts when the kernel try to
flush huge images to the underlying storage.

Future qemu-img and qemu-nbd are expected to implement "auto" cache and
aio modes, selecting --cache=none and --aio=native if possible. This
change implements this in our qemu_nbd wrapper so we can use this now
with current qemu version.

When starting qemu_nbd.Server(), if cache was not specified, we select
cache="none" if the image can be opened with direct I/O. If aio was not
specified, we select it based on the cache value.

Signed-off-by: Nir Soffer nsoffer@redhat.com

@nirs nirs added enhancement Enhancing the system by adding new feature or improving performance or reliability performance labels Mar 13, 2022
@nirs nirs requested review from vjuranek, bennyz and barpavel March 13, 2022 02:53
@nirs
Copy link
Member Author

nirs commented Mar 13, 2022

Tested using backup stress test:
https://gitlab.com/nirs/ovirt-stress/-/tree/master/backup

2022-03-13 10:37:49,122 INFO (MainThread) 64 full backups, 896 incremental backups, 0 failed, 960 passed, 0 errored in 333.8 minutes

The test use imageio client to download backups and created checksum of the backup. With this
change all the backups use --cache=none --aio=native on the client side.

bennyz
bennyz previously approved these changes Mar 13, 2022
Previously we use --cache=writeback and --aio=threads so we can access
images on file system that does not support direct I/O. This is
sometimes faster than --cache=none and --aio=native, but typically give
less consistent results, and pollute the page cache with image data,
which is mostly likely will never be used.

When uploading and downloading images on a hypervisor, using the page
cache can be harmful and cause sanlock timeouts when the kernel try to
flush huge images to the underlying storage.

Future qemu-img and qemu-nbd are expected to implement "auto" cache and
aio modes, selecting --cache=none and --aio=native if possible. This
change implements this in our qemu_nbd wrapper so we can use this now
with current qemu version.

When starting qemu_nbd.Server(), if cache was not specified, we select
cache="none" if the image can be opened with direct I/O. If aio was not
specified, we select it based on the cache value.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs nirs merged commit 186e005 into oVirt:master Mar 13, 2022
Copy link
Member

@barpavel barpavel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good, just 1 question about 2 logs.

# Implement "auto" cache mode, planned for qemu 7.
if self.cache is None:
self.cache = "none" if self._can_use_direct_io() else "writeback"
log.debug("Using cache=%r", self.cache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this log.debug() be out of the if (so it will be printed always)?
Same for line #99.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is logged only if we cache was automatically set. If the user set the cache to explicit value, we use it as is so there is no need to log.

@nirs nirs deleted the auto-cache branch March 27, 2022 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancing the system by adding new feature or improving performance or reliability performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants