From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 04C2D7FB13 for ; Mon, 1 Dec 2014 14:01:07 +0100 (CET) Received-SPF: Neutral (mail2-smtp-roc.national.inria.fr: domain of simon.cruanes.2007@m4x.org does not assert whether or not 129.104.30.34 is permitted sender) identity=pra; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=xpn7=AV=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="simon.cruanes.2007@m4x.org"; x-conformance=sidf_compatible; x-record-type="spf2.0" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of SRS0=xpn7=AV=m4x.org=simon.cruanes.2007@bounces.m4x.org designates 129.104.30.34 as permitted sender) identity=mailfrom; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=xpn7=AV=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="SRS0=xpn7=AV=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-conformance=sidf_compatible; x-record-type="spf2.0" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@mx1.polytechnique.org designates 129.104.30.34 as permitted sender) identity=helo; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=xpn7=AV=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="postmaster@mx1.polytechnique.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuYBABxmfFSBaB4inGdsb2JhbABbg1dYgwXDYIYMgVQWAQEBAQERAQEBAQEICwkJFC6EAwEBBCNWEAshIQICDwVJiFMNvQKWM5N3gVMFlVKGdIFrl1VuBYJCAQEB X-IPAS-Result: AuYBABxmfFSBaB4inGdsb2JhbABbg1dYgwXDYIYMgVQWAQEBAQERAQEBAQEICwkJFC6EAwEBBCNWEAshIQICDwVJiFMNvQKWM5N3gVMFlVKGdIFrl1VuBYJCAQEB X-IronPort-AV: E=Sophos;i="5.07,493,1413237600"; d="scan'208";a="110461913" Received: from mx1.polytechnique.org ([129.104.30.34]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 01 Dec 2014 14:00:56 +0100 Received: from emmental.inria.fr (emmental.inria.fr [128.93.0.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 2DCE1140C55C4; Mon, 1 Dec 2014 14:00:55 +0100 (CET) Date: Mon, 1 Dec 2014 14:00:54 +0100 From: Simon Cruanes To: Thomas Gazagnaire Cc: OCaml users Message-ID: <20141201130053.GM37610@emmental.inria.fr> References: <20141201094430.GA8862@fuck_yeah> <591F1716-EE97-4A11-8CFA-A073ED5E64C3@gazagnaire.org> <20141201105227.GB8862@fuck_yeah> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3rzwkXnKuCXxoL5m" Content-Disposition: inline In-Reply-To: <20141201105227.GB8862@fuck_yeah> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Mon Dec 1 14:00:55 2014 +0100 (CET)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.000107, queueID=4851C140C55C5 X-Org-Mail: simon.cruanes.2007@polytechnique.org Subject: Re: [Caml-list] [ANN] cconv-0.2 --3rzwkXnKuCXxoL5m Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable So, it is possible (by changing slightly the interface of encoders to avoid an intermediate structure), to obtain the following (I also added a benchmark for decoding, comparing cconv to ppx_deriving_yojson): =3D=3D=3D=3D=3D=3D BEGIN BENCH =3D=3D=3D=3D=3D=3D % ./run_bench.native encoding... benchmark points Throughputs for "manual", "cconv", "deriving_yojson" each running for at le= ast 4 CPU seconds: manual: 4.18 WALL ( 4.18 usr + 0.00 sys =3D 4.18 CPU) @ 2826676= .15/s (n=3D11818333) cconv: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 941618.= 68/s (n=3D3951032) deriving_yojson: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 2824134= .70/s (n=3D11867014) Rate cconv deriving_yojson manual cconv 941619/s -- -67% -67% deriving_yojson 2824135/s 200% -- -0% manual 2826676/s 200% 0% -- benchmark terms Throughputs for "manual", "cconv", "deriving_yojson" each running for at le= ast 4 CPU seconds: manual: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 1125111= .48/s (n=3D4723218) cconv: 4.21 WALL ( 4.21 usr + 0.00 sys =3D 4.21 CPU) @ 789967.= 68/s (n=3D3324184) deriving_yojson: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 1100920= .75/s (n=3D4626069) Rate cconv deriving_yojson manual cconv 789968/s -- -28% -30% deriving_yojson 1100921/s 39% -- -2% manual 1125111/s 42% 2% -- decoding... benchmark points Throughputs for "cconv", "deriving_yojson" each running for at least 3 CPU = seconds: cconv: 3.16 WALL ( 3.16 usr + 0.00 sys =3D 3.16 CPU) @ 493501.= 11/s (n=3D1558970) deriving_yojson: 3.15 WALL ( 3.15 usr + 0.00 sys =3D 3.15 CPU) @ 1248812= .96/s (n=3D3932512) Rate cconv deriving_yojson cconv 493501/s -- -60% deriving_yojson 1248813/s 153% -- benchmark terms Throughputs for "cconv", "deriving_yojson" each running for at least 3 CPU = seconds: cconv: 3.12 WALL ( 3.12 usr + 0.00 sys =3D 3.12 CPU) @ 577372.= 88/s (n=3D1800826) deriving_yojson: 3.14 WALL ( 3.14 usr + 0.00 sys =3D 3.14 CPU) @ 1492303= .95/s (n=3D4688819) Rate cconv deriving_yojson cconv 577373/s -- -61% deriving_yojson 1492304/s 158% -- ./run_bench.native 45.01s user 1.16s system 99% cpu 46.181 total =3D=3D=3D=3D=3D=3D END BENCH =3D=3D=3D=3D=3D=3D It is still slower to encode records (intermediate list), and decoding also has some overhead. However, this is the cost of translating between the type and the JSON representation; I think it should be negligible compared to the actual IO + printing/parsing cost. The new, more efficient interface will probably appear in a future release. With ppx_deriving_cconv that shouldn't be too big a problem... Cheers, Le Mon, 01 Dec 2014, Simon Cruanes a =C3=A9crit : > Le Mon, 01 Dec 2014, Thomas Gazagnaire a =C3=A9crit : > > Do you have any benchmarks to compare CConv and similar camlp4 generato= rs? >=20 > Hi Thomas, >=20 > I hadn't, but I just wrote very basic ones to compare with > ppx_deriving_yojson (should be similar to camlp4). The code is at > https://github.com/c-cube/cconv/blob/e80ab0e6c458a01b419ea69c7f41d0a350ae= bbad/bench/run_bench.ml >=20 > It only compares times for encoding into Json right now, with the > following results (recursive records first, recursive terms then; > "manual" is a handwritten encoding function, "cconv" the combinators > version, and "deriving_yojson" uses @whitequark's nice deriver): >=20 > % ./run_bench.native >=20 > benchmark points > Throughputs for "manual", "cconv", "deriving_yojson" each running for at = least 4 CPU seconds: > manual: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 30572= 70.82/s (n=3D12846652) > cconv: 4.21 WALL ( 4.21 usr + 0.00 sys =3D 4.21 CPU) @ 78472= 4.92/s (n=3D3300553) > deriving_yojson: 4.21 WALL ( 4.21 usr + 0.00 sys =3D 4.21 CPU) @ 30657= 79.07/s (n=3D12891601) > Rate cconv manual deriving_yojson > cconv 784725/s -- -74% -74% > manual 3057271/s 290% -- -0% > deriving_yojson 3065779/s 291% 0% -- >=20 > benchmark terms > Throughputs for "manual", "cconv", "deriving_yojson" each running for at = least 4 CPU seconds: > manual: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 16796= 09.71/s (n=3D7057720) > cconv: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 72661= 9.43/s (n=3D3051075) > deriving_yojson: 4.20 WALL ( 4.20 usr + 0.00 sys =3D 4.20 CPU) @ 16247= 40.65/s (n=3D6822286) > Rate cconv deriving_yojson manual > cconv 726619/s -- -55% -57% > deriving_yojson 1624741/s 124% -- -3% > manual 1679610/s 131% 3% -- --=20 Simon http://weusepgp.info/ key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3 7D8D 4AC0 1D08 49AA 62B6 --3rzwkXnKuCXxoL5m Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUfGaFAAoJEErAHQhJqmK2Yv0P/R4BeV6GIYpi09a4NGiCox2+ FopTIBotZ8LcJxfPEoBCUHH26NjK5V+ZQ1rCf3lS/gH6W/40mY143yrOGdXMQJSV LoYVF5MtC3VTyY7bjBmH4qIaPEOREIdd3s1cuVr9Je4HVPeJLkZbrZ5V6amtUK6K 3MbKqoQ5VcPM2TChAqVmXkpeVruBXi6/zdbaeCSgVQyEMkr9XKWvMA/TjCgsfdG9 F2og8VcMbsCeN+/0Zj/eH0KI5muNqcByUUi/NjmIdN2RTRODaNvO2/p61i/fea+I wHhfDXNhFi7p8YAgWCCC+i7mvcsYSd2bfkgRmMALthtOdfj3HVx597OCK5hX19Th Cq59LZJJVCq0HK1wAvQpOB4HD2Q9RKJpBqCpI691+7VA+bqlTq6r56YBhNcN0zBY fu+0vJPOtt5t+MEPi/B85SSKipiNMJdXmIW7Lv5y0Dlk32nenPce1dZIHdgETOZC M17OPSQOsbHQVKKMFEE5byDKHpcPtydXX7F+90DQ1k3Pd6tQF3pFKXzjlBf5QzwO bMv4CpwQnwgNpZhMsR1D8Jai1eIu68MzqO1XKlARwZTn4xlXwBExMcBcI1Xl9H9S NA7KG3ahDztWncreqame8p4K5XurYm6y4le52sLuZE/6whGLCI9ZZ2CaBkI2y80w FgVntstntBKeSniA4DlR =wbSD -----END PGP SIGNATURE----- --3rzwkXnKuCXxoL5m--