From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 05B8E7EE99 for ; Mon, 20 Jan 2014 11:09:46 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcCAIv13FLU4xEMnGdsb2JhbABZugeFT4EMFg4BAQEBAQYNCQkUKIIlAQEBBDpPCxgJJQ8FKIgkARi9Ih+GDhePBhaEIgSYIYYxEo8E X-IPAS-Result: ArcCAIv13FLU4xEMnGdsb2JhbABZugeFT4EMFg4BAQEBAQYNCQkUKIIlAQEBBDpPCxgJJQ8FKIgkARi9Ih+GDhePBhaEIgSYIYYxEo8E X-IronPort-AV: E=Sophos;i="4.95,689,1384297200"; d="scan'208";a="53981051" Received: from mout.web.de ([212.227.17.12]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 20 Jan 2014 11:09:45 +0100 Received: from frosties.localnet ([37.49.32.119]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0LmxtE-1VO8oe1mG4-00h968 for ; Mon, 20 Jan 2014 11:09:44 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1W5Bnb-0007HB-UZ for caml-list@inria.fr; Mon, 20 Jan 2014 11:09:44 +0100 Date: Mon, 20 Jan 2014 11:09:43 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20140120100943.GH26447@frosties> References: <523666417617602473@orange.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:PXGjWC4kzrmNfVq3/918evP7W2R53LxvNiRxh/ZkEITn9J8TJ8y vFcY1v0qwT4Z7ScsUgbubZe3vNCvbhCMYFXq2/r2Qs7e1kYwwVZsq+wlO0wy4j7wn3opzLB ZWtAyKuVZ6+YCDPLXEsy6zMQZQD+LKpnEUrZR54Tf2FPpLWtFiEhZBpqh4YzeMM390ZN8Ky 0coksWAZhnD/yOqZntVOw== Subject: Re: [Caml-list] How much optimized is the 'a option type ? On Fri, Jan 17, 2014 at 09:36:22AM -0500, Markus Mottl wrote: > Others have already answered about memory representation, but there is > one thing about allocations that many OCaml programmers may not yet be > aware of and that can make a noticeable performance difference when > used wisely: the OCaml compiler will inspect your code and, under the > right conditions, batch together allocations. E.g. consider this > function (references are records, btw.): > > let f n = > let x = ref (ref (Some (Some n))) in > [(x, n); (x, n)] > > One might naively assume that this would lead to seven or so > allocations. But if you inspect the assembly, you'll see only one > allocation followed by mere initialization assignments. Cool. Didn't know that. Thanks for whoever implemented that. MfG Goswin