From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 63D1F8240C for ; Sun, 15 Apr 2018 18:16:14 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=d.o.teller@gmail.com; spf=Pass smtp.mailfrom=d.o.teller@gmail.com; spf=None smtp.helo=postmaster@mail-wr0-f181.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of d.o.teller@gmail.com) identity=pra; client-ip=209.85.128.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="d.o.teller@gmail.com"; x-sender="d.o.teller@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of d.o.teller@gmail.com designates 209.85.128.181 as permitted sender) identity=mailfrom; client-ip=209.85.128.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="d.o.teller@gmail.com"; x-sender="d.o.teller@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wr0-f181.google.com) identity=helo; client-ip=209.85.128.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="d.o.teller@gmail.com"; x-sender="postmaster@mail-wr0-f181.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AGNn7Ex9J0qxdXf9uRHKM819IXTAuvvDOBiVQ1KB3?= =?us-ascii?q?2+4cTK2v8tzYMVDF4r011RmVBd6ds6oMotGVmpioYXYH75eFvSJKW713fDhBt/?= =?us-ascii?q?8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1?= =?us-ascii?q?Ifn+FpLPg8it2O2+55Pebx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+?= =?us-ascii?q?RZ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F5hSI2RHEUykEHHydozCVe1fRjiVJ5pNmyIF?= =?us-ascii?q?WfCdRosl2Avm4AO8zPx7I+7Q9zcwupfq1dwz7OrWw0JhvQdoBtiQhjneB1p/mX?= =?us-ascii?q?kFEmdvjfJP5Hdlw1LG6pBWxvlRFNhd/fRMC15oOpvVzug8ANf3CFuYIoW5DW2+?= =?us-ascii?q?S9DjOgkfC8oryoZXMUl4EtSmyBvE2njyWuJHp/mwHJUxt5nk8T3xKsJ6kSiU0a?= =?us-ascii?q?Agixw5WJMKOzT23+hw8A/cA4OPmEKcxf6n?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BWBADsedNahrWAVdFcgyCBNIEig2aDb?= =?us-ascii?q?ZEmgUsIIYEPh0qNGQsjhGACgi0ZBwEENBQBAgEBAQEBAQEBARMBAQEICwsIKCM?= =?us-ascii?q?MgjUigkwBAgECIx0BGx4DDAYFCw0CAiYCAiMRAQUBAhoTCAEBGoRWAQMVAQ6ZC?= =?us-ascii?q?zyLBYF/BQEXgm8Fg0YKGSYNVFeCJwIGCQEId4Z9ghOBMgyBOXUugVSBJhcCAQK?= =?us-ascii?q?CKYI0glQCl2QIhVmIXAaBboVKhROJLIZMAgQCBAUCBQ8hgQQzgXMzGiNQMYISC?= =?us-ascii?q?YIlGoM0hRSFQG2OZAEB?= X-IPAS-Result: =?us-ascii?q?A0BWBADsedNahrWAVdFcgyCBNIEig2aDbZEmgUsIIYEPh0q?= =?us-ascii?q?NGQsjhGACgi0ZBwEENBQBAgEBAQEBAQEBARMBAQEICwsIKCMMgjUigkwBAgECI?= =?us-ascii?q?x0BGx4DDAYFCw0CAiYCAiMRAQUBAhoTCAEBGoRWAQMVAQ6ZCzyLBYF/BQEXgm8?= =?us-ascii?q?Fg0YKGSYNVFeCJwIGCQEId4Z9ghOBMgyBOXUugVSBJhcCAQKCKYI0glQCl2QIh?= =?us-ascii?q?VmIXAaBboVKhROJLIZMAgQCBAUCBQ8hgQQzgXMzGiNQMYISCYIlGoM0hRSFQG2?= =?us-ascii?q?OZAEB?= X-IronPort-AV: E=Sophos;i="5.48,455,1517871600"; d="scan'208";a="262111962" Received: from mail-wr0-f181.google.com ([209.85.128.181]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 15 Apr 2018 18:16:13 +0200 Received: by mail-wr0-f181.google.com with SMTP id d1so19541189wrj.13 for ; Sun, 15 Apr 2018 09:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jPf2XnNStBmdlOjXcY2YxKoAuaUBVoFVcsFS41Ab1vo=; b=PD+oKO0rezzTdKh6vpNZdNwJunmrIa9wWED2MI7RvN5exDbKMI82kpd3dyRx0ZiUNO 8NjqobgcHluZXMR6TXCZBVrtrpdPF4XyTG8Z3kyRDVsLRbjdrr2BSnG/7b1sBVRSel/6 Z3DEJCO3PPiiOBxeopb+HOD/oMfJxsJng0znfRTEa6TElPAA70C9D5phwKNnCTtpOXXe lWhknwkRojLmdYnLntndBPNRT664ZeqA5sHBTWOJNZ/ps1gZRp+NrbAN4pDd1L/qEqtw G7hZlVRFW7g1sdwJvyUxIne24ed1sywEvG2QwcsY9JbUPOwGtMRC1WyevdFUXNdxRUzR GrZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jPf2XnNStBmdlOjXcY2YxKoAuaUBVoFVcsFS41Ab1vo=; b=g4Lrf4nBf7j0QIytTWjnh56xmZt6WmIIrV27PPEGEVX9w7OoyLp+lZScSDXm5Hrt03 tJ7ZxQ1umiCQ+pjvqySExUYpjgHjL4Mh8r4S20xbGKMrcZfcj/dZka3pivC8L4Kzo2Hi 1rinFk+Ht8T3vl/aK5Uz81vAvnrDhJlZNGJ1orXu6jtWO2qI8NB6F3P1t+Kpm6fZF2JL KUVI/bg+riClbLikDSd6eh4YekrHbH4niAbPv0jUM52MjbfbwRd/K3Y3iZpMQ/bn8iG4 MENJeB5VvxiVTlzqYyupkua1p7Reh0P9e0DEZsEJtoekomsQm+tf984hJ+gAXgce8HUj aUtA== X-Gm-Message-State: ALQs6tDqQNy8vEg1Od1cXeUu3eyB1IkAFZg3t0l+Pra4VLHKUE99XzVP Zp3EFIOyDsseMaj/i18LX1tLXsNW X-Google-Smtp-Source: AIpwx48bMiYIqqAQtZA8wQIk/XGROlkcJqegsPch0NfUuTM2VqSdqMGBh1IfnZJLaPKD29uCh7rzbA== X-Received: by 10.28.146.136 with SMTP id u130mr5915165wmd.125.1523808972699; Sun, 15 Apr 2018 09:16:12 -0700 (PDT) Received: from Napoleon.local ([2a01:e0a:ee:e280:9806:8712:f331:9be]) by smtp.gmail.com with ESMTPSA id y191sm9323382wme.14.2018.04.15.09.16.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 09:16:11 -0700 (PDT) From: David Teller X-Google-Original-From: David Teller To: caml-list@inria.fr References: <1ecada996e0b0d0069daf03241622159@free.fr> <6618a201557cf5ede5aaf15eb0ed21d8@starynkevitch.net> Openpgp: preference=signencrypt Message-ID: <587a5888-629b-1257-2035-4fefc0308ab5@gmail.com> Date: Sun, 15 Apr 2018 18:16:10 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <6618a201557cf5ede5aaf15eb0ed21d8@starynkevitch.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Validation-by: d.o.teller@gmail.com Subject: Re: [Caml-list] Would it be possible to add automatic, region-based memory management to OCaml? I seem to remember that the relative performance of GC vs. manual memory allocation depends a lot of how much additional memory the allocator can use in addition to the memory actually allocated to the mutator (i.e. the program). From the top of my head, even with a pretty good GC, you need to be at ~100% additional memory for the allocator before the performance of the GC breaks even with good manual allocation. Now, I don't remember where this number comes from, so I could be wrong. In addition, region-based resource management can have a number of other benefits, such as predictable destructors, as in Rust. There is a recent paper on extending OCalm with, basically, the Rust ownership model by Jonathan Goodwin: http://jondgoodwin.com/pling/gmm.pdf . In this paper, you need to explicitly differentiate between owned data and gc-ed data, as there are differences in both typing (owned data has affine types) and semantics (owned data has destructors, rather than finalizers). Cheers, David On 09/04/2018 14:26, Basile Starynkevitch wrote: > This is naive. GC is not "lost time", it is acceptable run-time overhead. > > Imagine you rewrite your code in e.g. Rust or C++. Then you still need > to allocate (and deallocate) heap memory. And that cost CPU time and > memory overhead. > > So, even if by magic you replace the GC by some region-based memory > allocation, you won't win in practice 20% > > To say it otherwise, even C malloc or C++ ::operator new have some > measurable overhead; in some programs it is more than 20%. > > In practice, Ocaml's GC is very well written and is one of the most > competitive ones. And the GC is intimately tied to the code generator, > so changing the GC would require significant compiler changes. > > There is no silver bullet. https://en.wikipedia.org/wiki/No_Silver_Bullet > > A good tutorial on GC is http://gchandbook.org/ > > Cheers. > >