[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 08/10] xbzrle: check 8 bytes at a time after
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v5 08/10] xbzrle: check 8 bytes at a time after an concurrency scene |
Date: |
Fri, 4 Apr 2014 20:52:42 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
* address@hidden (address@hidden) wrote:
> From: ChenLiang <address@hidden>
>
> The logic of old code is correct. But Checking byte by byte will
> consume time after an concurrency scene.
>
> Signed-off-by: ChenLiang <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
> ---
> xbzrle.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/xbzrle.c b/xbzrle.c
> index 92cccd7..9d67309 100644
> --- a/xbzrle.c
> +++ b/xbzrle.c
> @@ -51,16 +51,24 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t
> *new_buf, int slen,
>
> /* word at a time for speed */
> if (!res) {
> - while (i < slen &&
> - (*(long *)(old_buf + i)) == (*(long *)(new_buf + i))) {
> - i += sizeof(long);
> - zrun_len += sizeof(long);
> - }
> -
> - /* go over the rest */
> - while (i < slen && old_buf[i] == new_buf[i]) {
> - zrun_len++;
> - i++;
> + while (i < slen) {
> + if ((*(long *)(old_buf + i)) == (*(long *)(new_buf + i))) {
> + i += sizeof(long);
> + zrun_len += sizeof(long);
> + } else {
> + /* go over the rest */
> + for (j = 0; j < sizeof(long); j++) {
> + if (old_buf[i] == new_buf[i]) {
> + i++;
> + zrun_len++;
> + } else {
> + break;
> + }
> + }
> + if (j != sizeof(long)) {
> + break;
Is it not possible to make this code the same as the other loop, you could xor
in the same
way just change the comparison?
(What do other people think - I was thinking that would just be better since it
would
be symmetric?)
Dave
> + }
> + }
> }
> }
>
> --
> 1.7.12.4
>
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v5 09/10] migration: optimize xbzrle by reducing data copy, (continued)
- [Qemu-devel] [PATCH v5 03/10] migration: expose the bitmap_sync_count to the end, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 05/10] XBZRLE: optimize XBZRLE to decrease the cache misses, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 01/10] XBZRLE: Fix one XBZRLE corruption issues, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 04/10] migration: expose xbzrle cache miss rate, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 06/10] XBZRLE: rebuild the cache_is_cached function, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 07/10] xbzrle: don't check the value in the vm ram repeatedly, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 02/10] migration: Add counts of updating the dirty bitmap, arei.gonglei, 2014/04/04
- [Qemu-devel] [PATCH v5 08/10] xbzrle: check 8 bytes at a time after an concurrency scene, arei.gonglei, 2014/04/04
- Re: [Qemu-devel] [PATCH v5 08/10] xbzrle: check 8 bytes at a time after an concurrency scene,
Dr. David Alan Gilbert <=
- Re: [Qemu-devel] [PATCH v5 00/10] migration: Optimizate the xbzrle and fix one corruption issue, Dr. David Alan Gilbert, 2014/04/04
- [Qemu-devel] For 2.0? Re: [PATCH v5 00/10] migration: Optimizate the xbzrle and fix one corruption issue, Eric Blake, 2014/04/04