Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Optimizing symbolic processing code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-16 (14:15)
From: Hugo Ferreira <hmf@i...>
Subject: Re: [Caml-list] Optimizing symbolic processing code
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

~/workspace/planner$ time swipl -f -g "win(A, B, C, D, E, F), 
/home/hugof/workspace/planner/docs/ 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: 
>> 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 

Was afraid of that.