qcow2: Optimize L2 table cache size based on image and cluster sizes
A message that is not in the archive (sent off-list or not yet received): [email protected]
[ Restoring the CC list, adding Eric for QAPI ]
Am 06.10.2016 um 20:36 hat Frank Myhr geschrieben:
Quoted 13 lines
Thanks Alberto for pointing me to Ed Swierk's patch and this discussion.
Quoted 9 lines · Alberto Garcia
Frank Myhr's suggestion (in bugzilla) is that we allow specifying a % of the disk size, so
l2-cache-size=100% (that would be cache-size=max) l2-cache-size=80%
...
Quoted 8 lines
Quoted 3 lines
[This] would change however the data type of 'l2-cache-size' from int to string in BlockdevOptionsQcow2, can we actually do that?
Maybe pass a negative integer to indicate percentage, so string is not required?:
l2-cache-size=-100 (l2-cache-size=max, covers entire drive)
l2-cache-size=-50 (l2-cache-size=50% of max, covers half of drive)
l2-cache-size=2097152 (l2-cache-size=2M)
No, this is the kind of magic that is best to avoid.
If you want to have two different ways to configure the cache, make it two different options.
Quoted 6 lines
On Wed 5 Oct 2016 17:13:39 +0200, Max Reitz wrote;
Quoted 3 lines
maybe it would make more sense to introduce a whole new set of options called {,l2-,refcount-}cache-coverage or something. These options would then accept both an absolute and a relative number.
Quoted 8 lines
Quoted 1 line · Kevin Wolf
If we want easy, make it easy: cache-coverage and apply it to both.
refcount-cache-size if unspecified is now automatically set to l2-cache-size / 4, correct? So if we could specify l2-cache-size as "max" or in percentage, it seems that refcount-cache-size is already taken care if we if just leave it unspecified.
Yes.
Quoted 11 lines · Alberto Garcia
Quoted 3 lines
I don't think it's a good
idea to have two ways to specify exactly the same thing, when one can be converted to the other with a very simple operation.I agree. For better or worse we already have l2-cache-size. If its accepted values can be slightly expanded, using either a "max" enum as Max Reitz suggested, or somehow indicating a relative (percentage) value rather than an absolute number of bytes, this seems to offer sufficient flexibility for a broad range of users.
Quoted 5 lines
Although the percentage of max l2 cache size isn't exactly an intuitive number to specify, it's also (as Alberto notes) equal to the percentage of drive size covered by the cache. That's only marginally harder to think about than the absolute drive size covered by cache that a cache-coverage parameter would specify.
I think we can add "max" as an additional accepted value to l2-cache-size, but if we want to allow percentages, that should be a separate option (because we can't easily parse "50%" with QAPI except if treating it as a string, but that wouldn't be quite right).
Kevin
Quoted 9 lines · Kevin Wolf
Quoted 4 lines
Maybe pass a negative integer to indicate percentage, so string is not required?:
l2-cache-size=-100 (l2-cache-size=max, covers entire drive)
l2-cache-size=-50 (l2-cache-size=50% of max, covers half of drive)
l2-cache-size=2097152 (l2-cache-size=2M)No, this is the kind of magic that is best to avoid.
If you want to have two different ways to configure the cache, make it two different options.
I agree. Still, I would like to know what's the use case you (Frank, Ed) are thinking about:
- Are we talking about command-line options, QMP, or both?
- Do you know the size of the disk image or you want to be able to set the cache size without having access to that information? In other words, what's preventing you from calculating the cache size that you need?
Berto
Quoted 4 lines · Alberto Garcia
I would like to know what's the use case you (Frank, Ed) are thinking about:
- Are we talking about command-line options, QMP, or both?
Command-line options alone are sufficient for my use case, which is configuring and starting VMs using libvirt.
Quoted 4 lines
- Do you know the size of the disk image or you want to be able to set the cache size without having access to that information? In other words, what's preventing you from calculating the cache size that you need?
I know the disk image size, and can set cache size in bytes. l2-cache-size=max would be a convenience feature, *especially if it could become the default*. Then I could forget thinking about whether the image is larger than the current 8GB fully-cached threshold, and only have to calculate cache size in bytes in case of very large images, multiple backing files, or very tight memory.
Frank
Quoted 12 lines · Frank Myhr
Quoted 6 lines · Alberto Garcia
I would like to know what's the use case you (Frank, Ed) are thinking about:
- Are we talking about command-line options, QMP, or both?
Command-line options alone are sufficient for my use case, which is configuring and starting VMs using libvirt.
Quoted 7 lines
Quoted 4 lines
- Do you know the size of the disk image or you want to be able to set the cache size without having access to that information? In other words, what's preventing you from calculating the cache size that you need?
I know the disk image size, and can set cache size in bytes. l2-cache-size=max would be a convenience feature, *especially if it could become the default*. Then I could forget thinking about whether the image is larger than the current 8GB fully-cached threshold, and only have to calculate cache size in bytes in case of very large images, multiple backing files, or very tight memory.
Same here, using libvirt. l2-cache-size=max would be ideal. Or if there were a cache-coverage-size option that takes an absolute number, libvirt could set it to the image size.
--Ed
Quoted 10 lines · Ed Swierk
Quoted 6 lines
I know the disk image size, and can set cache size in bytes. l2-cache-size=max would be a convenience feature, *especially if it could become the default*. Then I could forget thinking about whether the image is larger than the current 8GB fully-cached threshold, and only have to calculate cache size in bytes in case of very large images, multiple backing files, or very tight memory.
Same here, using libvirt. l2-cache-size=max would be ideal. Or if there were a cache-coverage-size option that takes an absolute number, libvirt could set it to the image size.
I can see the benefit of both approaches: setting the disk size covered by the cache or setting a percentage, I personally like a bit more the former but it wouldn't provide a way to say "create the largest cache needed for this disk".
Would 'l2-cache-coverage-size' work for everyone? It would simply take the disk size (16G, 1T, etc) and it would conflict with l2-cache-size.
Do we need something similar for the refcount cache?
Berto
Quoted 9 lines · Alberto Garcia
Quoted 3 lines · Ed Swierk
Same here, using libvirt. l2-cache-size=max would be ideal. Or if there were a cache-coverage-size option that takes an absolute number, libvirt could set it to the image size.
I can see the benefit of both approaches: setting the disk size covered by the cache or setting a percentage, I personally like a bit more the former but it wouldn't provide a way to say "create the largest cache needed for this disk".
I prefer percentage (or just 'max') because it eliminates a source of performance problems when increasing the size of a VM's disk(s). Take the case of a VM doing heavy random I/O on a 10GB disk. Admin1 initially sets l2-cache-size=1.25M or l2-cache-coverage-size=10G. At some point the disk fills up as they always do, and admin2 (or admin1 on a bad day) increases its size to 20GB: problem solved. Except admin2 forgot to also double l2-cache-size or l2-cache-coverage-size. So performance with larger drive takes a nosedive (~*6X* worse in your worst-case benchmark) until some admin figures it out.
Sure, admins shouldn't make this mistake. But guaranteed they (cough, I) will. Using percentage makes this mistake impossible.
Quoted 2 lines
Would 'l2-cache-coverage-size' work for everyone? It would simply take the disk size (16G, 1T, etc) and it would conflict with l2-cache-size.
The above said, l2-cache-coverage-size would work for me if libvirt could set it. Or if it defaulted to entire image size, eliminating the need for libvirt to set it, and making impossible the admin mistake above.
Quoted 1 line
Do we need something similar for the refcount cache?
I don't know. AFAICT the current default refcount behavior is fine. But might be good to keep l2 and refcount options symmetrical.
Frank