multi-thread-compression.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. Use multiple thread (de)compression in live migration
  2. =====================================================
  3. Copyright (C) 2015 Intel Corporation
  4. Author: Liang Li <liang.z.li@intel.com>
  5. This work is licensed under the terms of the GNU GPLv2 or later. See
  6. the COPYING file in the top-level directory.
  7. Contents:
  8. =========
  9. * Introduction
  10. * When to use
  11. * Performance
  12. * Usage
  13. * TODO
  14. Introduction
  15. ============
  16. Instead of sending the guest memory directly, this solution will
  17. compress the RAM page before sending; after receiving, the data will
  18. be decompressed. Using compression in live migration can help
  19. to reduce the data transferred about 60%, this is very useful when the
  20. bandwidth is limited, and the total migration time can also be reduced
  21. about 70% in a typical case. In addition to this, the VM downtime can be
  22. reduced about 50%. The benefit depends on data's compressibility in VM.
  23. The process of compression will consume additional CPU cycles, and the
  24. extra CPU cycles will increase the migration time. On the other hand,
  25. the amount of data transferred will decrease; this factor can reduce
  26. the total migration time. If the process of the compression is quick
  27. enough, then the total migration time can be reduced, and multiple
  28. thread compression can be used to accelerate the compression process.
  29. The decompression speed of Zlib is at least 4 times as quick as
  30. compression, if the source and destination CPU have equal speed,
  31. keeping the compression thread count 4 times the decompression
  32. thread count can avoid resource waste.
  33. Compression level can be used to control the compression speed and the
  34. compression ratio. High compression ratio will take more time, level 0
  35. stands for no compression, level 1 stands for the best compression
  36. speed, and level 9 stands for the best compression ratio. Users can
  37. select a level number between 0 and 9.
  38. When to use the multiple thread compression in live migration
  39. =============================================================
  40. Compression of data will consume extra CPU cycles; so in a system with
  41. high overhead of CPU, avoid using this feature. When the network
  42. bandwidth is very limited and the CPU resource is adequate, use of
  43. multiple thread compression will be very helpful. If both the CPU and
  44. the network bandwidth are adequate, use of multiple thread compression
  45. can still help to reduce the migration time.
  46. Performance
  47. ===========
  48. Test environment:
  49. CPU: Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz
  50. Socket Count: 2
  51. RAM: 128G
  52. NIC: Intel I350 (10/100/1000Mbps)
  53. Host OS: CentOS 7 64-bit
  54. Guest OS: RHEL 6.5 64-bit
  55. Parameter: qemu-system-x86_64 -accel kvm -smp 4 -m 4096
  56. /share/ia32e_rhel6u5.qcow -monitor stdio
  57. There is no additional application is running on the guest when doing
  58. the test.
  59. Speed limit: 1000Gb/s
  60. ---------------------------------------------------------------
  61. | original | compress thread: 8
  62. | way | decompress thread: 2
  63. | | compression level: 1
  64. ---------------------------------------------------------------
  65. total time(msec): | 3333 | 1833
  66. ---------------------------------------------------------------
  67. downtime(msec): | 100 | 27
  68. ---------------------------------------------------------------
  69. transferred ram(kB):| 363536 | 107819
  70. ---------------------------------------------------------------
  71. throughput(mbps): | 893.73 | 482.22
  72. ---------------------------------------------------------------
  73. total ram(kB): | 4211524 | 4211524
  74. ---------------------------------------------------------------
  75. There is an application running on the guest which write random numbers
  76. to RAM block areas periodically.
  77. Speed limit: 1000Gb/s
  78. ---------------------------------------------------------------
  79. | original | compress thread: 8
  80. | way | decompress thread: 2
  81. | | compression level: 1
  82. ---------------------------------------------------------------
  83. total time(msec): | 37369 | 15989
  84. ---------------------------------------------------------------
  85. downtime(msec): | 337 | 173
  86. ---------------------------------------------------------------
  87. transferred ram(kB):| 4274143 | 1699824
  88. ---------------------------------------------------------------
  89. throughput(mbps): | 936.99 | 870.95
  90. ---------------------------------------------------------------
  91. total ram(kB): | 4211524 | 4211524
  92. ---------------------------------------------------------------
  93. Usage
  94. =====
  95. 1. Verify both the source and destination QEMU are able
  96. to support the multiple thread compression migration:
  97. {qemu} info migrate_capabilities
  98. {qemu} ... compress: off ...
  99. 2. Activate compression on the source:
  100. {qemu} migrate_set_capability compress on
  101. 3. Set the compression thread count on source:
  102. {qemu} migrate_set_parameter compress-threads 12
  103. 4. Set the compression level on the source:
  104. {qemu} migrate_set_parameter compress-level 1
  105. 5. Set the decompression thread count on destination:
  106. {qemu} migrate_set_parameter decompress-threads 3
  107. 6. Start outgoing migration:
  108. {qemu} migrate -d tcp:destination.host:4444
  109. {qemu} info migrate
  110. Capabilities: ... compress: on
  111. ...
  112. The following are the default settings:
  113. compress: off
  114. compress-threads: 8
  115. decompress-threads: 2
  116. compress-level: 1 (which means best speed)
  117. So, only the first two steps are required to use the multiple
  118. thread compression in migration. You can do more if the default
  119. settings are not appropriate.
  120. TODO
  121. ====
  122. Some faster (de)compression method such as LZ4 and Quicklz can help
  123. to reduce the CPU consumption when doing (de)compression. If using
  124. these faster (de)compression method, less (de)compression threads
  125. are needed when doing the migration.