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 9AC367F89E for ; Thu, 3 Apr 2014 22:31:34 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=80.12.242.128; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=80.12.242.128; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.smtpout.orange.fr) identity=helo; client-ip=80.12.242.128; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@smtp.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsoDAN/DPVNQDPKAeGdsb2JhbABYDsgGgTYOARUmKoIlAQEFOEABEBkKCRYPCQMCAQIBRQYBDAEHAQGHec9BF45xB4Q4AQOYW4ZRjV5/Qg X-IPAS-Result: AsoDAN/DPVNQDPKAeGdsb2JhbABYDsgGgTYOARUmKoIlAQEFOEABEBkKCRYPCQMCAQIBRQYBDAEHAQGHec9BF45xB4Q4AQOYW4ZRjV5/Qg X-IronPort-AV: E=Sophos;i="4.97,790,1389740400"; d="scan'208";a="66301455" Received: from smtp06.smtpout.orange.fr (HELO smtp.smtpout.orange.fr) ([80.12.242.128]) by mail2-smtp-roc.national.inria.fr with ESMTP; 03 Apr 2014 22:31:34 +0200 Received: from [192.168.1.24] ([81.249.80.103]) by mwinf5d64 with ME id lYXZ1n0072DkosZ03YXZ2A; Thu, 03 Apr 2014 22:31:33 +0200 Message-ID: <533DC52E.9000707@frisch.fr> Date: Thu, 03 Apr 2014 22:31:42 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Leo White , Thomas Braibant CC: John Whitington , "caml-list@inria.fr" References: <5332F937.1030303@coherentgraphics.co.uk> <86eh1oacmq.fsf@cam.ac.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Caml-list] More efficient compilation of functors? (was: Wrapping up the Set module in another) On 4/3/2014 4:28 PM, Leo White wrote: > The main additional cost would come from calling `Set.Make` in > `set_of_list` and creating new modules in `set_of_list` and `insert`. > `Set.Make` has to create a lot of closures which capture the `compare` > function. I think these closures are all allocated at once, but this > still means a lot of assignments. Creating the new modules is a record > allocation and assignment of all the record fields. I'm wondering whether an alternative compilation scheme could make functor instantiation much faster. Instead of having individual closures for all (non-closed) functions the functor exports, one could create a single big closure representing all functions at once. It would typically contain the functor's argument itself, plus other non functional values computed during the functor's body initialization (or maybe one could even keep a reference to the block representing the functor's result). The closure would be allocated at the beginning (with dummy values) and filled along the evaluation of the body. -- Alain