Skip to content
  • Alberto Garcia's avatar
    af39bd0d
    qcow2: Default to 4KB for the qcow2 cache entry size · af39bd0d
    Alberto Garcia authored
    
    
    QEMU 2.12 (commit 1221fe6f) introduced
    a new setting called l2-cache-entry-size that allows making entries on
    the qcow2 L2 cache smaller than the cluster size.
    
    I have been performing several tests with different cluster and entry
    sizes and all of them show that reducing the entry size (aka L2 slice)
    consistently improves I/O performance, notably during random I/O (all
    tests done with sequential I/O show similar results). This is to be
    expected because loading and evicting an L2 slice is more expensive
    the larger the slice is.
    
    Here are some numbers on fully populated 40GB qcow2 images. The
    rightmost column represents the maximum L2 cache size in both cases.
    
       Cluster size = 64 KB
       |-------------+--------------+--------------+--------------|
       |             | 1MB L2 cache | 3MB L2 cache | 5MB L2 cache |
       |-------------+--------------+--------------+--------------|
       |  4KB slices |    6545 IOPS |   12045 IOPS |   55680 IOPS |
       | 16KB slices |    5177 IOPS |    9798 IOPS |   56278 IOPS |
       | 64KB slices |    2718 IOPS |    5326 IOPS |   57355 IOPS |
       |-------------+--------------+--------------+--------------|
    
       Cluster size = 256 KB
       |--------------+----------------+--------------+-----------------|
       |              | 512KB L2 cache | 1MB L2 cache | 1280KB L2 cache |
       |--------------+----------------+--------------+-----------------|
       |   4KB slices |      8539 IOPS |   21071 IOPS |      55417 IOPS |
       |  64KB slices |      3598 IOPS |    9772 IOPS |      57687 IOPS |
       | 256KB slices |      1415 IOPS |    4120 IOPS |      58001 IOPS |
       |--------------+----------------+--------------+-----------------|
    
    As can be seen in the numbers, the only exception to the rule is when
    the cache is large enough to hold all L2 tables. This is also to be
    expected because in this case no cache entry is ever evicted so
    reducing its size doesn't bring any benefit.
    
    This patch sets the default L2 cache entry size to 4KB except when the
    cache is large enough for the whole disk.
    
    Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    af39bd0d
    qcow2: Default to 4KB for the qcow2 cache entry size
    Alberto Garcia authored
    
    
    QEMU 2.12 (commit 1221fe6f) introduced
    a new setting called l2-cache-entry-size that allows making entries on
    the qcow2 L2 cache smaller than the cluster size.
    
    I have been performing several tests with different cluster and entry
    sizes and all of them show that reducing the entry size (aka L2 slice)
    consistently improves I/O performance, notably during random I/O (all
    tests done with sequential I/O show similar results). This is to be
    expected because loading and evicting an L2 slice is more expensive
    the larger the slice is.
    
    Here are some numbers on fully populated 40GB qcow2 images. The
    rightmost column represents the maximum L2 cache size in both cases.
    
       Cluster size = 64 KB
       |-------------+--------------+--------------+--------------|
       |             | 1MB L2 cache | 3MB L2 cache | 5MB L2 cache |
       |-------------+--------------+--------------+--------------|
       |  4KB slices |    6545 IOPS |   12045 IOPS |   55680 IOPS |
       | 16KB slices |    5177 IOPS |    9798 IOPS |   56278 IOPS |
       | 64KB slices |    2718 IOPS |    5326 IOPS |   57355 IOPS |
       |-------------+--------------+--------------+--------------|
    
       Cluster size = 256 KB
       |--------------+----------------+--------------+-----------------|
       |              | 512KB L2 cache | 1MB L2 cache | 1280KB L2 cache |
       |--------------+----------------+--------------+-----------------|
       |   4KB slices |      8539 IOPS |   21071 IOPS |      55417 IOPS |
       |  64KB slices |      3598 IOPS |    9772 IOPS |      57687 IOPS |
       | 256KB slices |      1415 IOPS |    4120 IOPS |      58001 IOPS |
       |--------------+----------------+--------------+-----------------|
    
    As can be seen in the numbers, the only exception to the rule is when
    the cache is large enough to hold all L2 tables. This is also to be
    expected because in this case no cache entry is ever evicted so
    reducing its size doesn't bring any benefit.
    
    This patch sets the default L2 cache entry size to 4KB except when the
    cache is large enough for the whole disk.
    
    Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading