From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb8rI-0003RA-8l for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yb8rD-0000E9-AH for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:34:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yb8rD-0000Dz-3f for qemu-devel@nongnu.org; Thu, 26 Mar 2015 10:34:03 -0400 Date: Thu, 26 Mar 2015 14:33:58 +0000 From: Stefan Hajnoczi Message-ID: <20150326143358.GB630@stefanha-thinkpad.redhat.com> References: <201501262119592629551@sangfor.com.cn> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MfFXiAuoTsnnDAfZ" Content-Disposition: inline In-Reply-To: <201501262119592629551@sangfor.com.cn> Subject: Re: [Qemu-devel] [RFC] optimization for qcow2 cache get/put List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhang Haoyu Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel --MfFXiAuoTsnnDAfZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 26, 2015 at 09:20:00PM +0800, Zhang Haoyu wrote: > Hi, all >=20 > Regarding too large qcow2 image, e.g., 2TB, > so long disruption happened when performing snapshot, > which was caused by cache update and IO wait. I have CCed Kevin Wolf, the qcow2 maintainer. > perf top data shown as below, > PerfTop: 2554 irqs/sec kernel: 0.4% exact: 0.0% [4000Hz cycles],= (target_pid: 34294) > -------------------------------------------------------------------------= ----------------------------------------------- >=20 > 33.80% qemu-system-x86_64 [.] qcow2_cache_do_get =20 > 27.59% qemu-system-x86_64 [.] qcow2_cache_put =20 > 15.19% qemu-system-x86_64 [.] qcow2_cache_entry_mark_dirty =20 > 5.49% qemu-system-x86_64 [.] update_refcount =20 > 3.02% libpthread-2.13.so [.] pthread_getspecific =20 > 2.26% qemu-system-x86_64 [.] get_refcount =20 > 1.95% qemu-system-x86_64 [.] coroutine_get_thread_state =20 > 1.32% qemu-system-x86_64 [.] qcow2_update_snapshot_refcount > 1.20% qemu-system-x86_64 [.] qemu_coroutine_self =20 > 1.16% libz.so.1.2.7 [.] 0x0000000000003018 =20 > 0.95% qemu-system-x86_64 [.] qcow2_update_cluster_refcount=20 > 0.91% qemu-system-x86_64 [.] qcow2_cache_get =20 > 0.76% libc-2.13.so [.] 0x0000000000134e49 =20 > 0.73% qemu-system-x86_64 [.] bdrv_debug_event =20 > 0.16% qemu-system-x86_64 [.] pthread_getspecific@plt =20 > 0.12% [kernel] [k] _raw_spin_unlock_irqrestore =20 > 0.10% qemu-system-x86_64 [.] vga_draw_line24_32 =20 > 0.09% [vdso] [.] 0x000000000000060c =20 > 0.09% qemu-system-x86_64 [.] qcow2_check_metadata_overlap =20 > 0.08% [kernel] [k] do_blockdev_direct_IO =20 >=20 > If expand the cache table size, the IO will be decreased,=20 > but the calculation time will be grown. > so it's worthy to optimize qcow2 cache get and put algorithm. >=20 > My proposal: > get: > using ((use offset >> cluster_bits) % c->size) to locate the cache entry, > raw implementation, > index =3D (use offset >> cluster_bits) % c->size; > if (c->entries[index].offset =3D=3D offset) { > goto found; > } >=20 > replace: > c->entries[use offset >> cluster_bits) % c->size].offset =3D offset; > ... >=20 > put: > using 64-entries cache table to cache > the recently got c->entries, i.e., cache for cache, > then during put process, firstly search the 64-entries cache, > if not found, then the c->entries. >=20 > Any idea? >=20 > Thanks, > Zhang Haoyu >=20 --MfFXiAuoTsnnDAfZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVFBjWAAoJEJykq7OBq3PI7j8IAISjnvSSnlDERCDUtVPxXu+y rWMfj9XwSP+Mxxy92lsRk1b+khAe26xfae9cg5zkNkVyTv046GzQLeyxsudto35I +T/JdQrYhhVj/p/gdyEw2Xqp4FdvsK9uFJA9Ygh1Uw/200IUlAhrCxNospx1JXLc HYHjEjeeNJQ1NnTsYs3OmcksRXBDgsr/ibXuCB1WeSSt9kaEZhVgNCqPzVhOuuqN HMLbJYVxPjNg1tRtEazAPOuVg4gy6ZM7Q9nMl92sorn8i/UWqi89eF7lIUWPZpX7 52DLgO7evsOtMN4tAPZU3Y0U6r4Gj0T0g+/WnV6tx6LMfVh0/HjdzuBv68N4lkk= =scWy -----END PGP SIGNATURE----- --MfFXiAuoTsnnDAfZ--