From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqoF0-0003rX-W0 for qemu-devel@nongnu.org; Fri, 08 May 2015 15:47:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqoEw-0005Ko-0m for qemu-devel@nongnu.org; Fri, 08 May 2015 15:47:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqoEv-0005KU-P4 for qemu-devel@nongnu.org; Fri, 08 May 2015 15:47:17 -0400 Message-ID: <554D12C3.8040308@redhat.com> Date: Fri, 08 May 2015 13:47:15 -0600 From: Eric Blake MIME-Version: 1.0 References: <1430864578-22072-1-git-send-email-jsnow@redhat.com> <1430864578-22072-5-git-send-email-jsnow@redhat.com> <87pp6eusrz.fsf@blackfin.pond.sub.org> <554A2142.7090006@redhat.com> <87y4l13f8z.fsf@blackfin.pond.sub.org> <554A3EE1.6050207@redhat.com> <554BCAB0.9030707@redhat.com> <87lhgzr3g1.fsf@blackfin.pond.sub.org> <554CE2CA.2080005@redhat.com> In-Reply-To: <554CE2CA.2080005@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ggeNdN1eNkWCuf4lvgCMVeKPThVET6qdM" Subject: Re: [Qemu-devel] [PATCH v3 4/5] qtest: precompute hex nibs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , Markus Armbruster Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ggeNdN1eNkWCuf4lvgCMVeKPThVET6qdM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/08/2015 10:22 AM, John Snow wrote: >>> I'm a bit surprised - making a function call per byte generally execu= tes >>> more instructions than open-coding the conversion (albeit the branch >>> prediction in the hardware probably does fairly well over long string= s, >>> since it is a tight and predictable loop). Remember, sprintf() has t= o >>> decode the format string on every call (unless the compiler is smart >>> enough to open-code what sprintf would do). >> >> John's measurements show that the speed difference between snprintf() >> and a local copy of formatting code gets thoroughly drowned in noise. >> >> The snprintf() version takes 18 lines less, according to diffstat. Le= ss >> code, same measured performance, what's not to like? >> >> However, if you feel strongly about avoiding snprintf() here, I won't >> argue further. Except for the commit message: it needs to be fixed no= t >> to claim avoiding "printf and friends" makes a speed difference. >> >=20 > My reasoning was the same as Markus's: the difference was so negligible= > that I went with the "less home-rolled code" version. >=20 > I already staged this series without the nib functions and submitted th= e > snprintf version as its own patch with a less disparaging (to printf an= d > friends) commit message. >=20 > Any further micro-optimization is a waste of time to properly benchmark= > and split hairs. I already dropped the test from ~14s to ~4s. Good enou= gh. Okay, I'm convinced - keep the s[n]printf, on the grounds that it wasn't the bottleneck. You are right that premature optimization is not worth the complexity if it gives no real speed gain. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ggeNdN1eNkWCuf4lvgCMVeKPThVET6qdM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVTRLDAAoJEKeha0olJ0Nqr28H/if7z7rn0N0LHaKm/ibwnGKr U4ONKa56EbF8Ayc3TG3/g1+MeYjq9mnF9N/azyn8st4gt0ws9oMwGSz1kk77uXM8 jojnJ939zsZxVjm62iKmMpKXt4zBB+jDH9P7LMq6SJSfABo97xw1RRUVEvSbBJpg 4dHgCUw8wf4mWfxdG5FXyR8qJqszGRoLYHgZeH63OB2hkJ2GAyK83A3leLs7J6SE Htls1EKtfpUSeY7N9IoxRZ54FzENU4nOK1VEKZ3A/bJrkZ6yOzr18peoIV9Zd6kx Ix+oJc+zYyv6EtkSoN3Ad9skNDrlR48P/qCnO5BuWh9b9XjSumIhQOnid/UxFZo= =Mkq1 -----END PGP SIGNATURE----- --ggeNdN1eNkWCuf4lvgCMVeKPThVET6qdM--