qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liang Li <liang.z.li@intel.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, yang.z.zhang@intel.com,
	Liang Li <liang.z.li@intel.com>,
	dgilbert@redhat.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] migration: optimization for one decompression thread
Date: Tue, 25 Aug 2015 19:59:10 +0800	[thread overview]
Message-ID: <1440503950-14174-4-git-send-email-liang.z.li@intel.com> (raw)
In-Reply-To: <1440503950-14174-1-git-send-email-liang.z.li@intel.com>

When decompression thread count is set to 1, the current implementation
is inefficient because of the following reason:
1. Thread syncronization cost;
2. Data copy;

This patch optimizes the performance for the case of 1 decompress thread.
In this case, the compression is done in process_incoming_migration_co,
for some fast decompression algorithm, it can help to improve the
performance.

Signed-off-by: Liang Li <liang.z.li@intel.com>
---
 migration/ram.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 0cc4f81..fc91997 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1414,6 +1414,9 @@ void migrate_decompress_threads_create(void)
     int i, thread_count;
 
     thread_count = migrate_decompress_threads();
+    if (thread_count == 1) {
+        return;
+    }
     decompress_threads = g_new0(QemuThread, thread_count);
     decomp_param = g_new0(DecompressParam, thread_count);
     compressed_data_buf = g_malloc0(compressBound(TARGET_PAGE_SIZE));
@@ -1432,8 +1435,11 @@ void migrate_decompress_threads_join(void)
 {
     int i, thread_count;
 
-    quit_decomp_thread = true;
     thread_count = migrate_decompress_threads();
+    if (thread_count == 1) {
+        return;
+    }
+    quit_decomp_thread = true;
     for (i = 0; i < thread_count; i++) {
         qemu_mutex_lock(&decomp_param[i].mutex);
         qemu_cond_signal(&decomp_param[i].cond);
@@ -1575,7 +1581,14 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
                 break;
             }
             qemu_get_buffer(f, compressed_data_buf, len);
-            decompress_data_with_multi_threads(compressed_data_buf, host, len);
+            if (migrate_decompress_threads() == 1) {
+                unsigned long pagesize = TARGET_PAGE_SIZE;
+                uncompress((Bytef *)host, &pagesize,
+                           (const Bytef *)compressed_data_buf, len);
+            } else {
+                decompress_data_with_multi_threads(compressed_data_buf,
+                                                   host, len);
+            }
             break;
         case RAM_SAVE_FLAG_XBZRLE:
             host = host_from_stream_offset(f, addr, flags);
-- 
1.9.1

      parent reply	other threads:[~2015-08-25 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 11:59 [Qemu-devel] [PATCH 0/3] Optimize the performance for single thread (de)compression Liang Li
2015-08-25 11:59 ` [Qemu-devel] [PATCH 1/3] qemu-file: improve qemu_put_compression_data Liang Li
2015-08-25 11:59 ` [Qemu-devel] [PATCH 2/3] migration: optimization for one compression thread Liang Li
2015-08-25 11:59 ` Liang Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440503950-14174-4-git-send-email-liang.z.li@intel.com \
    --to=liang.z.li@intel.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=yang.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).