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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6261E7EF29 for ; Fri, 18 Dec 2015 12:07:38 +0100 (CET) IronPort-PHdr: 9a23:meTv5xWsaohKVZSjfbLkGZRSz47V8LGtZVwlr6E/grcLSJyIuqrYZhCCt8tkgFKBZ4jH8fUM07OQ6PC+HzRYqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh770o8WbSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBIf9ZagxS/RnRGAkNHo548/0nRbGRAqLoHAbVzNFvABPBl3q4Qv2FqzttS/is+N73mHOPMv4Spg7VC6uqrx3TxvwjS4BMXg1/TeE2YRLkKtHrUf59FREyInObdTNOQ== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=info@gerd-stolpmann.de; spf=None smtp.mailfrom=info@gerd-stolpmann.de; spf=None smtp.helo=postmaster@mout.kundenserver.de Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.131; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CKAACk6HNWlIN+49Regw99bbh9hlQXBoVwAoE7PBABAQEBAQEBARABAQEBBwsLCR8wgi2CCAEBAwEnLh0HBQsLRlcGEwmIHgkDAQmrdm+QVwEBAQEBAQQBAQEBARUJhVqFeoRmglcMQYE2BYdcjyOBEgKFUIZniSKUATmCOxcHgVdxAYUQAQEB X-IPAS-Result: A0CKAACk6HNWlIN+49Regw99bbh9hlQXBoVwAoE7PBABAQEBAQEBARABAQEBBwsLCR8wgi2CCAEBAwEnLh0HBQsLRlcGEwmIHgkDAQmrdm+QVwEBAQEBAQQBAQEBARUJhVqFeoRmglcMQYE2BYdcjyOBEgKFUIZniSKUATmCOxcHgVdxAYUQAQEB X-IronPort-AV: E=Sophos;i="5.20,445,1444687200"; d="asc'?scan'208";a="157578454" Received: from mout.kundenserver.de ([212.227.126.131]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2015 12:07:04 +0100 Received: from office1.lan.sumadev.de ([178.4.219.171]) by mrelayeu.kundenserver.de (mreue005) with ESMTPSA (Nemesis) id 0LhAAN-1aW0gK0jbD-00oZfR; Fri, 18 Dec 2015 12:07:03 +0100 Received: from [IPv6:fd55:cf:6598:7f:d9c6:9d97:ba76:b927] (unknown [IPv6:fd55:cf:6598:7f:d9c6:9d97:ba76:b927]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 9536FDC05D; Fri, 18 Dec 2015 12:07:02 +0100 (CET) Message-ID: <1450436817.23408.54.camel@e130.lan.sumadev.de> From: Gerd Stolpmann To: Jordan W Cc: "caml-list@inria.fr" Date: Fri, 18 Dec 2015 12:06:57 +0100 In-Reply-To: References: Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-UFNIUlJQ3yHvzKn45JDq" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 X-Provags-ID: V03:K0:BdI7dXmR8EDQeuoZUv2zMbnn5jBlCd46CohwlQ8UE3gEOEdlXfD VDg/3jLE9zzWiHrePtS4U1iMNw2+njCKlxa755oXyRtlBShOyJJ4Ym4rxTHJaFKqmgzbFHQ /W2Us6YZN+SwGx6Hk5oaTiJV5VuNRT06Y0I81ml6s4lu1JxqbJpQMHMn/wrm8Zqjr1JfVOE mrHsvDyYO9eUQu+gT+L4w== X-UI-Out-Filterresults: notjunk:1;V01:K0:nvsejgRWySY=:3IL+0KWHaRURG+qBpztLVZ edSnmdlPlaAPRgePvHiFpY0RBxpych5JJNHgztsMaW84/t6BqfvGmcVE4O7aEC8FPyVjJbRB2 Y0ykmsKvvDYC8TQZcmm7nVFjihQ6rsEe/ZN+9ITvLt/PNA/B8OzovpWW/9KBvCoOUmlu2XbIJ rF3Z7Eq+bUHxrDvx2hQ8gjOPftigCPDcRyUB93RdrdY1vHzIA9PK80ZXwhjpW0ApZT4aPAyWj eQQw/6EZxiNpDYLs5X5ZAj2ktF6C3ckI8H0nrEUdCmOkDsLjCin4pja9A2Q/JBdwohu6FLs7v uZAT+NQPC+035T5nl8SVrdorBQ/a+BxKJGiSUHrG2ch+I/Ouq+TuOxgb3pCbMqQmMAHnSb0qT BeawxODcfupxquosKrzjd4NwoJi+nrpSKQWLNCWRvFw48FjhRmVBRaGTocFfaQSHp6m5rDQfl MUMS2bX3wN1LQDQ9FV0BNe24UcV5tWwK+t5zxxffWfUyKARS6pIloIqeHLBxLTA/alBHmey3a zp23pUU6cq/VyalG4y4xfhoTsUXXFRqfXcaowzT3AcQpiKbtkgnN6SOLNbW1axVfsBV5wDzSe mhF63ISmqGLHIEhgv0TZU63OzN9cXDqYgfL9o22yo/7qsXgUwJpIJyG/54s9/RrbSYrC43hh/ TchoWg0FibrxiRIVVSi4868500G7eng8u5PZfuetb2Lqr5n40TjYDZlVqeCG+2tSBZwY= Subject: Re: [Caml-list] Just how slow are classes? --=-UFNIUlJQ3yHvzKn45JDq Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable Am Freitag, den 18.12.2015, 00:19 -0800 schrieb Jordan W: > I am aware of some of the reasons why OCaml classes and objects are > slower than records. The lack of nominal subtyping makes determining > memory layout at compile time much more difficult. >=20 >=20 > While I am also curious why "nice cases" of objects/classes couldn't > be optimized (perhaps some link time check), when most of the objects > adhere to a nice hierarchy, I would like to defer that discussion > until another time. Oh, this is quickly explained. There is no hierarchy at runtime you can exploit. Remember that object X can be a subtype of object Y even if there is no inheritance relationship. This is very different from other OO languages. > For now, my primary question is: Just *how* slow are objects/classes? > Has there been any relevant benchmarking efforts that could shed some > light on this? It is essentially an additional hash table lookup. > For example, how much more expensive in terms of memory are objects > (compared to records). How much slower are property accesses and > method invocations than record accesses and module function > invocations? It is hard to give a number because function invocations can be cheap but also quite expensive when there are lots of arguments and many register spills. It also depends on whether you always call the same function or whether it changes every time (at the same point in the program, i.e. per generated indirect jump). Note that you can factor out the additional lookup when there are method arguments, e.g. if you have method foo : s -> t you can do this: let f =3D obj#foo and then later, e.g. in a loop f arg which is then only the function call, w/o method lookup. This doesn't work, though, when there are no method arguments. Gerd --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-UFNIUlJQ3yHvzKn45JDq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJWc+jRAAoJEAaM4b9ZLB5T4WUH/1LIxGE+9U7JGNTsr7PLIiJY XSL2TS6Vm5jIaUslOGEvC82Ndq1u5Nr+745bQ5tyq4k+H9iFqDj60i7YSCDX1d1k HwTIOIiJjSzT1buPWe/RBsOLGP/wuI76wXlKo+44mchn99BVnF0+OQ67AKllPdTC Kh24ecAqgRG+hYZPURmqpvTzHlSnAvKN/zmNklJ4uSdErkBCFmofBoF4GrHD4TbE H9/4iPLYCUDJkVvSim1l1gjKI4HMbADZGCTzK38VhwV6eufiCxK9fqVzeu9k8qjL /A5ihfMw4U1Ss6HVhKEjPM9w2BDPobU0ac4Al7vupFtrgR5t8mF/XbtqzLy/e4A= =k555 -----END PGP SIGNATURE----- --=-UFNIUlJQ3yHvzKn45JDq--