Skip to the content.

xbzrle

Add XBZRLE to ram_save_block and ram_save_live

In the outgoing migration check to see if the page is cached and
changed, then send compressed page by using save_xbrle_page function.
In the incoming migration check to see if RAM_SAVE_FLAG_XBZRLE is set
and decompress the page (by using load_xbrle function).

如果对于内存的修改是稀疏的,那么就可以进行压缩。

居然整体的架构是这个样子的:

static SaveVMHandlers savevm_ram_handlers = {
    .save_setup = ram_save_setup,
    .save_live_iterate = ram_save_iterate,
    .save_live_complete_postcopy = ram_save_complete,
    .save_live_complete_precopy = ram_save_complete,
    .has_postcopy = ram_has_postcopy,
    .save_live_pending = ram_save_pending,
    .load_state = ram_load,
    .save_cleanup = ram_save_cleanup,
    .load_setup = ram_load_setup,
    .load_cleanup = ram_load_cleanup,
    .resume_prepare = ram_resume_prepare,
};

https://github.com/qemu/qemu/blob/master/docs/xbzrle.txt

Using XBZRLE (Xor Based Zero Run Length Encoding) allows for the reduction of VM downtime and the total live-migration time of Virtual machines.

真的都可以降低吗?

为了访问计算 update,需要 cache 数据

The counter will increase after each ram dirty bitmap sync. When a cache conflict is detected, XBZRLE will only evict pages in the cache that are older than a threshold.

压缩算法

需要参考 xbzrle.c

Example
old buffer:
1001 zeros
05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 68 00 00 6b 00 6d
3074 zeros

new buffer:
1001 zeros
01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 68 00 00 67 00 69
3074 zeros

encoded buffer:

encoded length 24
e9 07 0f 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 03 01 67 01 01 69

page cache 的管理

主要的内容在 : page_cache.c

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。