<Drakken>
dsheets you need a space character in the middle.
<dsheets>
Drakken: \\b doesn't suffice?
<Drakken>
\\b doesn't use up any characters. It's just a boundary.
<Drakken>
between characters
<dsheets>
ohhhhh like ^ or $
<Drakken>
right
<dsheets>
thank you :-)
<Drakken>
you bet
MaskRay has quit [Remote host closed the connection]
letrec has joined #ocaml
datkin has joined #ocaml
datkin has quit [Ping timeout: 240 seconds]
KDr2 has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
iago has quit [Quit: Leaving]
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
cdidd has quit [Remote host closed the connection]
Tobu has quit [Ping timeout: 272 seconds]
fantasticsid has joined #ocaml
emmanuelux has quit [Remote host closed the connection]
fantasticsid has quit [Client Quit]
Tobu has joined #ocaml
andreypopp has joined #ocaml
twittard has joined #ocaml
fantasticsid has joined #ocaml
fantasticsid has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
andreypopp has quit [Read error: Connection reset by peer]
maufred_ has quit [Ping timeout: 244 seconds]
maufred has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
edwin has joined #ocaml
edwin1 has joined #ocaml
edwin has quit [Disconnected by services]
edwin1 has left #ocaml []
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
Snark has joined #ocaml
sithisbitch has joined #ocaml
sithisbitch has left #ocaml []
Xizor has joined #ocaml
Drup has joined #ocaml
Tobu has quit [Remote host closed the connection]
Tobu has joined #ocaml
cdidd has joined #ocaml
Cyanure has joined #ocaml
letrec has quit [Ping timeout: 265 seconds]
Kakadu has joined #ocaml
Anarchos has joined #ocaml
<Anarchos>
I have a program in C++ which communicate with an OCaml toplevel (stdin and stdout redirected through pipes). But as the printings of the toplevel are formatted, and truncated if too long, how can i get back long values from the toplevel ? Would it be better to communicate the values through sockets ?
<mrvn>
you could link in the loplevel and call stuff directly.
<mrvn>
otherwise it would be better to print stuf yourself instead on relying on the toplevel
<mrvn>
Connecting to dht:// [Searching: 16/34 nodes replied]
<mrvn>
ups
ousado has quit [Ping timeout: 276 seconds]
<Anarchos>
mrvn maybe i should explain the background :
<Anarchos>
The interface is in C++ and allow me to manipulate math formulas (PNG images generated by latex).
<Anarchos>
Then the formulas are send to my ocaml program which verify the coherence of the demonstration, and sends info back to the interface
Kakadu has quit [Quit: Konversation terminated!]
Kakadu has joined #ocaml
<mrvn>
How do I find out the number of cores the system (linux) has in ocaml?
<Anarchos>
maybe use the Sys or Unix interface to launch a shell command (uname -a) ?
<mrvn>
uname doesn't list the number of cores
<Anarchos>
sysinfo ?
<mrvn>
again no number of cores in there
<Anarchos>
with sysinfo i get "CPU #0 blabla" and "CPU #1 blibli"
<mrvn>
Oh, you mean the command, not the function call. command not found: sysinfo
<mrvn>
I would rather not rely on external commands.
<zorun>
or open /proc/cpuinfo and read from there
<mrvn>
Best idea I have so far is parsing /proc/cpuinfo
sander has joined #ocaml
Xizor has quit [Ping timeout: 260 seconds]
lamawithonel has joined #ocaml
<mrvn>
sysconf(_SC_NPROCESSORS_ONLN) helps
ulfdoz has quit [Quit: brb]
ulfdoz has joined #ocaml
iago has joined #ocaml
<Drakken>
Where is it specified what camlp4 does with BLANK and NEWLINE tokens?
<Drakken>
Apparently the lexer generates them from whitespace and newlines, so they must be processed in the parser somewhere.
<Drakken>
But I don't see anything about that in the manual, and I haven't found it yet in the source code.
<iZsh>
thelema: what was the url for the new API doc?
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
Submarine has quit [Ping timeout: 246 seconds]
MaskRay_ has joined #ocaml
MaskRay has quit [Quit: leaving]
MaskRay_ has quit [Client Quit]
MaskRay has joined #ocaml
MaskRay has quit [Changing host]
MaskRay has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
Cyanure has quit [Ping timeout: 260 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
ousado has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
edwin has joined #ocaml
edwin1 has joined #ocaml
edwin has quit [Disconnected by services]
edwin1 is now known as edwin
edwin1 has joined #ocaml
edwin has quit [Disconnected by services]
milosn has joined #ocaml
mehitabel has quit [*.net *.split]
thieusoai has quit [*.net *.split]
bitbckt has quit [*.net *.split]
mehitabel has joined #ocaml
ousado has quit [Changing host]
ousado has joined #ocaml
thieusoai has joined #ocaml
bitbckt has joined #ocaml
bitbckt has quit [Changing host]
bitbckt has joined #ocaml
emmanuelux has joined #ocaml
letrec has joined #ocaml
notk0 has joined #ocaml
Submarine has quit [Ping timeout: 252 seconds]
<Julien_T>
I there, I'm looking for an ocaml binding for libgphoto2. I only found a post on a forum where someone called eddy say he is working on this, but I can't find any trace of this.
<Julien_T>
has someone an idee ?
<notk0>
an idea*
<Julien_T>
yes sorry
<notk0>
Hello, is it possible to make the toplevel use a local module in a file? open doesn't seem to work
<mrvn>
yes but don't ask me how
<notk0>
I tried to do a #use on a cmo file
avsm has joined #ocaml
<notk0>
:|
<alpounet>
notk0, #load ?
<notk0>
alpounet, I have tried load, load works but it still says that the module is unbound
ftrvxmtrx_ has joined #ocaml
<alpounet>
hm
<notk0>
is it supposed to say something if it succeeds ? it just says #load "filename"
<alpounet>
The directive #load loads the file with the extension .cmo. In the later case, the global declarations of this file are not directly accessible. If the file example.ml contains the global declaration f, then once the bytecode is loaded (#load "example.cmo";;), it is assumed that the value of f could be accessed by Example.f, where the first letter of the file is capitalized.
<alpounet>
it should work
<notk0>
alpounet, after I do load "filename" it still says unbound module Filename
<alpounet>
weird
ftrvxmtrx has quit [Ping timeout: 246 seconds]
<iZsh>
notk0: #load and then open
<notk0>
iZsh, it tells me unbound module after the load
<iZsh>
try use then
<notk0>
iZsh, use seems to work, but I can't use it as a module now
<iZsh>
what do you mean?
<notk0>
it just loaded all the functions, it means I have to modify the code to not use Module.f but f, or create a module by hand
<iZsh>
weird, in the toplevel, to use the batteries libraries I usually do: #use "topfind";; #require "batteries";;
<iZsh>
then I can do BatList. or open BatList for instance
<notk0>
well, this module is hand-made, it's just an .ml file it's not a package in the lib folder or something
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
avsm has quit [Quit: Leaving.]
andreypopp has joined #ocaml
avsm has joined #ocaml
KDr2 has quit [Remote host closed the connection]
<Drakken>
What does it mean in revised syntax when a let binding in a do {...} block ends in a semicolon instead of "in"?
<Drakken>
And then the variable is used in the expression after the semicolon. I can't find that in the manual.
andreypopp has quit [Quit: Computer has gone to sleep.]
<mrvn>
Drakken: I'm guessing that means { old_record with some_field = new_value; }
<edwin1>
I like the missing error messages stuff too
<edwin1>
btw it doesn't parse C99 declarations inside for
<pippijn>
it will automatically use the shortest possible sample for a state/token combination
<pippijn>
edwin1: I know
<pippijn>
that's intentional
<edwin1>
k
<pippijn>
trivial to change, but I don't want to, yet
<pippijn>
not shortest possible, shortest one you entered
<edwin1>
hmm and what do you do about wrong messages?
<edwin1>
for example, if you write printf("test);
<edwin1>
it says "input.c:5:9: Unrecognised character '"'"
<pippijn>
that's a lexer error
<edwin1>
whereas it should say something about an unterminated string
<edwin1>
ah right
<pippijn>
I'll take care of that another ittime
<pippijn>
low priority
<pippijn>
the parser is much more interesting
<pippijn>
I'm off now
<edwin1>
bye
edwin1 has left #ocaml []
andreypopp has joined #ocaml
edwin1 has joined #ocaml
<iZsh>
pippijn:what did you change in menhir?
andreypopp has quit [Quit: Computer has gone to sleep.]
avsm has quit [Quit: Leaving.]
letrec has quit [Ping timeout: 255 seconds]
oriba has joined #ocaml
fraggle_laptop has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
andreypopp has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
datkin has joined #ocaml
andreypopp has joined #ocaml
emmanuelux has quit [Quit: @+]
datkin has quit [Ping timeout: 246 seconds]
Submarine has quit [Ping timeout: 246 seconds]
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
asdfhjkl has joined #ocaml
Cyanure has joined #ocaml
notk0 has quit [Remote host closed the connection]
andreypopp has joined #ocaml
lamawithonel has quit [Remote host closed the connection]
andreypopp has quit [Client Quit]
EmmanuelOga has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
Cyanure has quit [Ping timeout: 272 seconds]
lamawithonel has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
Tobu has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
andreypopp has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
andreypopp has quit [Client Quit]
notk0 has joined #ocaml
andreypopp has joined #ocaml
iago has quit [Quit: Leaving]
andreypopp has quit [Client Quit]
fraggle_laptop has quit [Remote host closed the connection]
twittard has quit [Quit: twittard]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
asdfhjkl has quit [Quit: Leaving]
lorilan has joined #ocaml
EmmanuelOga has joined #ocaml
andreypopp has joined #ocaml
twittard has joined #ocaml
EmmanuelOga has quit [Ping timeout: 244 seconds]
andreypopp has quit [Quit: Computer has gone to sleep.]
notk0 has quit [Quit: bye bye]
Snark has quit [Quit: Quitte]
Kakadu has quit [Quit: Konversation terminated!]
twittard has quit [Quit: twittard]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
andreypopp has joined #ocaml
Submarine has quit [Remote host closed the connection]
andreypopp has quit [Quit: Computer has gone to sleep.]
andreypopp has joined #ocaml
lorill has joined #ocaml
<lorill>
hi, I'm trying to learn ocaml. I made a basic a* implementation, but i notice it's 2x slower than my java version. Can someone help me finding what went wrong ?
<_habnabit>
before you do anything else, profile your code
<_habnabit>
for ocaml, I highly recommend using valgrind/callgrind + kcachegrind
<lorill>
I did. The calls count are similar in java and ocaml
Tobu has quit [Ping timeout: 272 seconds]
<lorill>
my guess would be that i didn't used the best data structure i could. It was much slower with an association list instead of Hashtbls
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
<_habnabit>
association lists? yikes
<_habnabit>
you might use the Map module
andreypopp has quit [Quit: Computer has gone to sleep.]
fraggle_laptop has joined #ocaml
<pippijn>
iZsh: error reporting
twittard has joined #ocaml
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
Cyanure has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
csmrfx has quit [Read error: Connection reset by peer]
<_habnabit>
lorill, wait, you only have call counts?
<_habnabit>
lorill, not self time/total time?
<thelema>
List.nth is a bad sign
<_habnabit>
yeah, replacing a lot of this stuff that uses lists with sets might be good
<thelema>
but you're right - profiling will give best idea of what's taking the most time.
<lorill>
well, i first profiled with gprof and had times, but 46% of the time was spend in "compare_val", which doesn't really help
<_habnabit>
yeah, gprof kind of blows
<_habnabit>
use callgrind
<lorill>
so i later compiled to bytecode to profile with ocamlprof, and get the call count
<lorill>
ok, i'll check this tool
<thelema>
lorill: it does help - what is calling compare_val?
<lorill>
no idea, i don't have any function with this name
<thelema>
compare_val is the built-in polymorphic compare function
<thelema>
it's used for =, <, etc.
<lorill>
ok
<thelema>
(maybe not =, but definitely <, etc.
<thelema>
If you're comparing large values (lists, trees, hashtables), this function will take a lot of time.
<lorill>
i don't think i am. I'm comparing ints, (int*int), and that should be all
<lorill>
i'll double check
<thelema>
if you're doing a *lot* of (int*int) compares, that could take up a good amount of time.
<thelema>
ah, I see... hashtbl of pairs of ints. That'd cause a high compare_val
<thelema>
especially if the hash function is crap.
<thelema>
why even bother with a hashtable - why not just use a 2d array?
<lorill>
i thought the lookup would be faster
<lorill>
with the 2d array, I have to read all values in the worst case
<thelema>
?? how does the hashtable not have the same problem?
<lorill>
(at first i used Hashtbl directly, without specifying type & hash, but th result were the same)
<lorill>
magic ?
<lorill>
i don't really know the internals, but I always thought that with the hash & buckets, the lookup would be faster
<lorill>
if it isn't, the map structure doesn't make any sense
<lorill>
but then again, maybe i'm missing something fundamental
<lorill>
it wouldn't surprise me
<thelema>
Hashtbl in OCaml is an array of linked lists
<thelema>
so if your hash function doesn't do a good job of distributing values, you'll end up having to check each element of a linked list to see if any have the desired key
<thelema>
Since your keys are pairs of small ints, an array makes lots more sense to me
<thelema>
Array lookup is faster than hashtbl lookup.
<lorill>
and if I understand well, the hash let us know in which array cell our value is, so we only have to traverse one pair of list
<lorill>
oh, i see know what you mean with the 2d array
<lorill>
yes, that would be faster
<lorill>
s/know/now/
<thelema>
That's probably not your biggest problem - L95-107 is probably a bigger waste of CPU - building a list of neighbors and then scanning through it to tell if two maze cells are neighbors?
<thelema>
First of all, List.iteri (fun i neighbor -> ...) neighbors
andreypopp has joined #ocaml
<thelema>
blah, not in stdlib, only in batteries
<lorill>
mmh, no, these lines don't do what you think
<thelema>
(and extlib and I bet core)
<lorill>
i build the list of neighbour, then explore them and give them a score
<lorill>
i don't check if they're neighbors after that
<thelema>
ok, my misunderstanding.
<lorill>
and my java implementation uses the exact same algorithm, with a hashmap too, so that wouldn't explain the timing difference
<thelema>
openset and closedset should be (int*int) Set.t, and you shouldn't be sorting them each time.
<thelema>
so you functorized the wrong data structure.
<thelema>
what does your java implementation use for openset/closedset?
<lorill>
i changed my code to use sets, now that i finally understood how to make them. The time went /4
<thelema>
that said, your java could use the same optimization
<lorill>
exactly
<lorill>
i volontarily used the same algo
<lorill>
List<Point> closedset = new ArrayList<Point>(); List<Point> openset = new ArrayList<Point>();
<lorill>
so basically, the same time i was using, the same kind of comparator, and a sort a each loop
<thelema>
why sort?
<lorill>
to get the best candidate. I could also traverse the list.
<thelema>
for heap-like behavior?
<thelema>
Then you want a heap.
<lorill>
ah, i made a mistake in my set comparison, my result are bad (forgot to look in the fscore map)
<lorill>
so now i have a related ocaml question
<thelema>
well, one place that ocaml is going to be penalized over java is that ocaml lists don't have efficient nth as java ArrayLists do.
<lorill>
to make a set, i must provide a compare function
<thelema>
Pervasives.compare is a good one.
Tobu has quit [Ping timeout: 272 seconds]
<thelema>
it's implemented by that compare_val function you saw in the profiler
<lorill>
nah, here i need to lookup the score and compare the score of the coords, not the coords themselves
<lorill>
but the score table isn't accessible in the generated module
edwin1 has quit [Remote host closed the connection]
<thelema>
then put the score first?
<thelema>
oh, no problem
<lorill>
the score is local to the function
<lorill>
and i can't make a local module, right ?
<thelema>
are you using ocaml 3.12?
<lorill>
yes
<thelema>
then you can.
<thelema>
let module ScoreSet = Set.Make(struct type t = int*int let compare a b = CoordTable.find fscore a - CoordTable.find fscore b end) in ...
<thelema>
have you replaced coordtable with a 2d array?
<lorill>
ah ha. I knew for the local open, not for the declaration
<lorill>
not yet
<thelema>
if not, at least use Hashtbl.hash for the hash function instead of your *64 hash
<thelema>
Instead of "List.nth lines 0", use "List.hd lines"
<thelema>
instead of "let () = ... in" inside larger functions, use "...;"
<thelema>
instead of "let maze_get maze coord = let x,y = coord in" use "let maze_get maze (x,y) ="
<thelema>
I get an error in your pasted code trying to readin your maze.txt
<pippijn>
is there a way to escape closing comment characters in a comment?
<pippijn>
I would like to write the C type "void(*)()" or "sizeof(void*)" in my comment
<thelema>
?? you want to include *) as part of a comment
<pippijn>
yes
<thelema>
ah, just put a space in between the * and )
<pippijn>
that's ugly
<pippijn>
then it becomes void( * )()
<pippijn>
and izeof ( void* )
<thelema>
the other alternative is to add an extra (* at the beginning of your comment
<pippijn>
how does that help?
<thelema>
ocaml comments nest, so for each *), you need a (* to pair with it
<pippijn>
then I have a stray (* in my documentation
<thelema>
(*(* *)*) is a valid comment
<_habnabit>
tuareg-mode doesn't support that :(
<thelema>
ok, you could put the *) within a string - "void(*)()"
<pippijn>
that doesn't help
<thelema>
_habnabit: are you sure? my typerex does, and it's using tuareg for coloring, I thought
<_habnabit>
oh hey it does
<thelema>
hmm, typerex doesn't like (* (* "*)" *) *)
<_habnabit>
last time I checked it didn't
<thelema>
which it should, by ocaml's grammar
<pippijn>
ocaml doesn't like that, either
<pippijn>
oh wait
<pippijn>
it does
<thelema>
pippijn: really? I was fairly sure it would be fine
<thelema>
:)
<thelema>
Yes, ocaml has some unusual features of its comment syntax
<thelema>
It turns out to be quite robust.
<pippijn>
what's wrong with this comment: (** The result of [sizeof(void"*)"]. The number of [char]s that fit into an object pointer. *)
<pippijn>
oh
<thelema>
pippijn: well, maybe ocamldoc won't like "" within []
<pippijn>
The result of "[sizeof(void*)]".
<pippijn>
it also doesn't like that
<pippijn>
I guess I'm out of luck
<thelema>
is it just ocamldoc or ocaml that has problems with that?
<thelema>
maybe ocamldoc isn't accurately reproducing the comment rules
<pippijn>
just ocamldoc
<pippijn>
but ocamldoc does like (** foo "*)" *)
<pippijn>
I think
<pippijn>
let me check :)
<pippijn>
actually no
<pippijn>
it just ends the comment at "*)
<thelema>
ok, so ocamldoc doesn't play by ocamlc's comment rules.
<thelema>
time to submit a bug
<_habnabit>
cool !
Tobu has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
<thelema>
lorill: instead of doing "for i = 0 to List.length l - 1 do let n = List.nth l i", use List.iter l
<thelema>
err, List.iter (fun n -> ... ) l
philtor has joined #ocaml
<philtor>
I'm running Ubuntu (well, Mint actually, but close enough) and the Ocaml package is installed
<philtor>
However, I've also installed ocaml 3.12 with godi
<thelema>
ok, which is in path?
<philtor>
$ which ocaml
<philtor>
/home/phil/godi-3.12.1.0/bin/ocaml
<thelema>
ok
<philtor>
However, I installed aurochs and it's using the system OCaml
<thelema>
maybe it installed to the system ocamlfind installation?
<philtor>
when I look at _build/ocamlc.where it says:
<philtor>
/usr/lib/ocaml
<thelema>
that's odd.
<thelema>
I guess it has its own configure that mis-identifies the ocaml compiler you want to use
<philtor>
If I run ocamlc -where from the command line:
<thelema>
ah, it seems that aurochs has "/usr/lib" hard-coded into their myocamlbuild as the system_lib_dir
<philtor>
ah, crap!
<philtor>
why do that if you're using ocamlc -where ?
<thelema>
although that doesn't explain the _build/ocamlc.where
<philtor>
true.
<thelema>
they do try ocamlc -where for the ocaml_local_dir
<lorill>
thelema: i'm reading and applying your suggestions, thanks. I can't test for now, i broke everything while trying to use sets, but i'm writing what you say
<philtor>
should I set the OCAMLDIR ?
<thelema>
lorill: I can't get your first code to run properly - some error with line lengths in maze.txt; possibly because it's a windows text file and I'm on unix
<thelema>
philtor: aurochs doesn't use ocamlfind for install, so just build it, write a META file for it, and run 'ocamlfind install aurochs META _build/<files to install>'
<philtor>
thelema: I think that in the aurochs Makefile when it does: OCAML_DIR=$(shell ocamlc -where)
<thelema>
philtor: the list of these is in the Makefile
<philtor>
thelema: and it picks the /usr/bin/ocaml
<thelema>
philtor: don't worry about any of that, even if you fix it all, it still won't ocamlfind install.
<philtor>
(the /usr/bin/ocamlc in this case)
<thelema>
(at least the version I have downloaded won't)
<pippijn>
Erreur inconnue lors du parse de see : foo).
<pippijn>
cool.. french
<philtor>
ok, I'll give that a try
<thelema>
lorill: I get a 2423 byte file that I bet still doesn't work
<thelema>
lorill: yes, still broken
<lorill>
:(
<thelema>
lorill: well, your parsing leaves a lot to be desired
sander has quit [Quit: Leaving]
<lorill>
still some set questions: why is compare called with twice the same element, when the set is empty ?
<lorill>
and it also looks like compare is called with some elements that aren't in the set ? that's really strange
<thelema>
If you're adding to an empty set, there shouldn't be any compare
<philtor>
actually, I don't understand where the bitstring_c.o target is in that Makefile.
<philtor>
What is running gcc?
<thelema>
builtin rules in make
<thelema>
n.o is made automatically from n.c with a recipe of the form ‘$(CC) $(CPPFLAGS) $(CFLAGS) -c’.
<philtor>
How can I get make to tell me what CFLAGS is?
<pippijn>
iteresting
<philtor>
-d doesn't do it..
<pippijn>
if I compact the heap manually at one key point in my program, time goes down from 7.9 to 7.2 seconds
andreypopp has joined #ocaml
<thelema>
philtor: add a new target that does echo $(CFLAGS)?
<thelema>
philtor: what's your "OCAMLLIB =" line in your makefile?
<philtor>
It is correct: OCAMLLIB = /home/phil/godi-3.12.1.0/lib/ocaml/std-lib
<pippijn>
whoa!
wagle has quit [Ping timeout: 240 seconds]
<pippijn>
making the minor heap 4MB brings the execution time down from 7.2 to 5.4 seconds
<pippijn>
with 8MB it's even 5.0 seconds
<lorill>
i found why my compare was crashing: it's also called when Set.mem is called, not only in insertions
<thelema>
yes, of course.
<thelema>
Set.mem needs to walk the tree too, comparing as it goes.
<pippijn>
oh wait, in words, so it's 64MB
<thelema>
pippijn: yes, tweaking the GC can lead to significant performance improvements
<philtor>
well, it's not in the CFLAGS
<thelema>
if you turn it off entirely, your program will run even faster, although it may consume all your ram. :)
<thelema>
may = will
<pippijn>
how to turn it off?
andreypopp has quit [Quit: Computer has gone to sleep.]
<thelema>
pippijn: that was intended as a joke, but I'm sure there's some combination of settings that will tell the GC never to run
<pippijn>
china sucks
<pippijn>
wordpress.com is blocked
<pippijn>
groups.google.com, too
<Ptival>
pippijn: is it just that you're "pre-allocating" what will eventually be needed anyway?
<pippijn>
Ptival: I don't know
<Ptival>
2 seconds is a lot still
<pippijn>
for a single file it goes down from 170ms to 100ms
wagle has joined #ocaml
<philtor>
Ok, seems like the fix is to add an explicit rule to build bitstring_c.o
<philtor>
bitstring_c.o:bitstring_c.c
<philtor>
$(CC) $(CFLAGS) -c $^
<thelema>
philtor: I assume there's no string "linux64" anywhere in any file in your bitstring dir
<philtor>
nowhere
<thelema>
quite odd.
<philtor>
I added that rule and it works fine. It's better if it's explicit anyway, I think, keeps people from scratching their heads trying to figure out what's happening there.
<philtor>
...too much make magic without it.
<lorill>
can a set actually store two values where compare = 0 ?
<thelema>
lorill: no.
Tobu has quit [Ping timeout: 260 seconds]
<lorill>
then i can't use a set
<thelema>
oops, then you'll have to also include the result of pervasives.compare if the scores are equal
<lorill>
i can have several coordinates with the same score
<lorill>
ah, ok
<lorill>
that explain a lot of things, actually
<thelema>
hmm, you will have trouble removing an item from your set if its fscore changes...
<thelema>
which is why you really want a heap instead of a set.
<lorill>
anyway, it didn't change a thing time-wise
<lorill>
still 2 times slower than my equivalent java version :-(
Tobu has joined #ocaml
<thelema>
lorill: Have you changed the for loop to a List.iter?
<thelema>
lorill: I wouldn't be too surprised, as they're able to do very impressive optimizations in the jvm
<thelema>
Actually, looking at things, openset stays pretty small throughout the program, but closedset becomes larger and larger as the program runs, and List.mem is O(n), so it'll have to do quadratic work to eliminate duplicate paths - can you change it to a simpler set - let module PSet = Set.Make(struct type t = int * int let compare = Pervasives.compare end)
<pippijn>
is the revised caml syntax any good?
thelema_ has joined #ocaml
<thelema_>
also, your use of List.filter in neighbor_nodes is not nearly as efficient as the java implementation of the same function
<lorill>
yes, PSet for closeset divides the time per two
cdidd has quit [Remote host closed the connection]
andreypopp has quit [Quit: Computer has gone to sleep.]
thelema has quit [Ping timeout: 272 seconds]
<thelema_>
I'm impressed that the java version can do a List scan so quickly, but I guess it's not doing random accesses to memory, but the elements are packed in an array
<lorill>
let neighbor_nodes maze (x, y) = let nodes = ref [] in if x > 0 then nodes :=(x-1, y) :: !nodes; if x < ((width maze) - 1) then nodes := (x+1, y) :: !nodes; if y > 0 then nodes :=(x, y-1) :: !nodes; if y < ((height maze) - 1) then nodes := (x, y+1) :: !nodes; !nodes
<pippijn>
ArrayList
andreypopp has joined #ocaml
<lorill>
but same time, so that's not the bottleneck
<pippijn>
what happens if you make an array of your list before scaning it?
<thelema_>
lorill: hard to tell. also, ocaml is not as optimized for mutable values as java (different tradeoffs in GC), so this isn't perfect for ocaml either
andreypopp has quit [Client Quit]
<thelema_>
pippijn: it would be worse, as it'd have to read the whole list to make an array
<pippijn>
ok
<thelema_>
the list gets an element added to it each time
<pippijn>
so you scan it only once
<lorill>
yes, if I change the java one to use LinkedList, the time goes *1.5
<pippijn>
ok, I didn't read it
<thelema_>
lorill: is there a java equivalent of set?
<thelema_>
SortedSet?
<lorill>
yes, HashSet or TreeSet
<lorill>
probably TreeSet if i understand how ocaml's set works