From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 1A209BB84 for ; Fri, 16 Jan 2009 15:15:50 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmQBADMlcEnVhjEYkWdsb2JhbACUAwEBAQEJCwoHEQO5eYVy X-IronPort-AV: E=Sophos;i="4.37,277,1231110000"; d="scan'208";a="22588592" Received: from ihsmtp02voda.lis.interhost.com (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail1-smtp-roc.national.inria.fr with ESMTP; 16 Jan 2009 15:15:49 +0100 Received: from [192.168.1.64] ([77.54.249.136]) by ihsmtp02cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 16 Jan 2009 14:13:13 +0000 Message-ID: <49709693.50201@inescporto.pt> Date: Fri, 16 Jan 2009 14:15:47 +0000 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Optimizing symbolic processing code References: <4970488C.9080104@inescporto.pt> <200901161341.53632.jon@ffconsultancy.com> In-Reply-To: <200901161341.53632.jon@ffconsultancy.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Jan 2009 14:13:13.0044 (UTC) FILETIME=[91481940:01C977E4] X-Spam: no; 0.00; inference:01 inference:01 compiler:01 iirc:01 ocaml:01 recursive:01 rewrites:01 iirc:01 ocaml:01 node:01 low-level:01 afaik:01 2009:98 trie:98 prolog:01 Jon Harrop wrote: > On Friday 16 January 2009 08:42:52 Hugo Ferreira wrote: >> Hello, >> >> I have implemented a simple Prolog like inference engine >> to be used in machine learning algorithms (ILP). My first >> basic test shows that inference is dismally slow (compared >> to a Prolog compiler). > > Can you quantify that? > Yes. Give or take a second I get the following embarrassingly large difference: ~/workspace/planner$ time swipl -f prolog.pl -g "win(A, B, C, D, E, F), halt." /home/hugof/workspace/planner/docs/prolog.pl compiled 0.00 sec, 8,560 bytes real 0m30.278s user 0m30.222s sys 0m0.012s ~/workspace/planner$ time ./itest_1.p.native real 19m12.786s user 19m6.728s sys 0m0.196s >> Consequently I am looking for information on optimizing the code. > > IIRC, the single most productive optimization I made to the Mathematica > implementation I wrote in OCaml was to check when recursive rewrites were > leaving an expression unaltered and return the original when possible to > avoid copying. I don't know if that is relevant here. > Unfortunately not. I am just scanning the Trie repeatedly. I do this using functional like code using only folds and finds. > Also IIRC, someone else wrote that they lashed together a quick Prolog > implementation in OCaml and were surprised to find it outperforming real > Prolog compilers. > Yep. Blue Strom has already pointed out the link. Not quite what I am looking for. >> I have found: >> >> http://ocaml.janestreet.com/?q=node/30 >> http://camltastic.blogspot.com/2008/05/optimizing-memory-allocation-and-loo >> ps.html >> >> Does anyone have any other links or articles I may look at? > > The articles on low-level optimization in the OCaml Journal are almost > certainly relevant. OCaml for Scientists covers data structure performance in > detail. No other sources are as comprehensive with regard to optimization > AFAIK. > Was afraid of that. Thanks. HF.