From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCtn-0006w0-5T for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUCtk-0006FQ-Dd for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:23275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCtk-0006E4-6g for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:16 -0400 From: Liang Li Date: Tue, 25 Aug 2015 19:59:10 +0800 Message-Id: <1440503950-14174-4-git-send-email-liang.z.li@intel.com> In-Reply-To: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> References: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> Subject: [Qemu-devel] [PATCH 3/3] migration: optimization for one decompression thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, yang.z.zhang@intel.com, Liang Li , dgilbert@redhat.com, quintela@redhat.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 --- 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