IRC channel logs

2017-06-09.log

back to list of logs

***_zxq9_ is now known as zxq9
<ArneBab_>sneek: later tell nalaginrut: the scoping, the data formats, and the type conversion.
<sneek>Okay.
<catonano>I just successfully wrapped a C function in Guile scheme and I'm so happy !
<ArneBab_>catonano: nice! congrats!
<catonano>ArneBab_: thanks :-)
***random-nickname is now known as random-nick
<amz3>héllo
<amz3>I'd like to raise the issue that paroneayea is AFAIK the only one that has access to @guilelang twitter account in particular
<amz3>As matter of fact, paroneayea is biased in the regard of what makes a good tweet for guile community
<amz3>WDYT should be done to deal with this situation?
<paroneayea>amz3: the maintainers also have access but I'm the only one who logs in. but I also don't log in often
<paroneayea>only about once or twice a month
<OrangeShark>hello everyone
<amz3>I explicitly highlighted @guilelang it's very unlikely that you missed my tweets related to guile
<paroneayea>amz3: I guess you're annoyed that I don't always repost your things, but I have reposted them sometimes?
<amz3>paroneayea: never
<amz3>same message is toping /r/guile
<amz3>Yes I am annoyed that the thing I've been working on 3 years is not reposted yes
<amz3>without getting any feedback
<paroneayea>hm, I thought I had. I've reposted something that davexunit posted about your blogpost in the past but nothing by you
<paroneayea>amz3: at any rate
<paroneayea>I just reposted your wiredtiger thing.
<daviid>hello guilers! I have a serious (performance related) problem using large images, 1GB or more, in Guile-CV, and talking to the vigra and vigra_c folks, they pretend it is a guile problem (typical 'the ball is in your camp':)), which I first very much doubt but then I have to prove this, so I did a few tests, time and profile and need help to interpret some figures... hope super pro profilers will shim in :):), let me expose the
<daviid>'problem'
<daviid>the code is here: http://git.savannah.gnu.org/cgit/guile-cv.git/tree/cv/impex.scm?h=devel, and for this chat let's just concentrate on im-load, which calls vigra-load-rgb-image, which cals im-make-channels (3 channels of approx 350MB each), then finally calls the vigra_c procedure vigra-importrgbaimage-c
<daviid>so, loading a 1GB image tales 5'10" in guile, 3.6 sec in vigrapython and 14" when using the same vigra_c binding but in mathlab (I don't use mathlab of course, I use ocxtave, but the vigra_c developer did that measure ...)
<daviid>to complete the figures, loading the exact same image in guile but using a libfreeimage takes 0.9sec
<daviid>so, to try to eliminate Guile as the 'culprit, I measured the time taken to allocate the 3 channels of 350MB, f32vectors actually, and this gives us:
<daviid>scheme@(guile-user)> ,time (im-make-channels 17711 20208 3)
<daviid>$1 = (#f32(0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 …) …)
<daviid>;; 0.538621s real time, 1.366837s run time. 1.286892s spent in GC.
<daviid>
<daviid>which is prety good right?
<daviid>this is on a very powerfull machine by the way, 12 cores 24GB of mem and 2 SSD (so the performance problem is not the hard disk, neither a mem, nor a cpu prob
<daviid>,time (im-load Pelota3-20X.tif) gives 5'10" so I profiled
<daviid>scheme@(guile-user)> ,profile (im-load "Pelota3-20X.tif")
<daviid>% cumulative self
<daviid>time seconds seconds procedure
<daviid> 50.00 155.48 155.48 anon #x556937b5b148
<daviid> 50.00 155.48 155.48 make-srfi-4-vector
<daviid> 0.00 310.96 0.00 cv/impex.scm:129:0:vigra-load-rgb-image
<daviid> 0.00 155.48 0.00 ice-9/threads.scm:284:4:loop
<daviid>---
<daviid>Sample count: 2
<daviid>Total time: 310.960342833 seconds (1.253158522 seconds in GC)
<daviid>
<daviid>first, I don't know how to interpret these numbers, I was expecting below a second for allocation and 5'9" spent in the vigra_c cv/impex.scm:129:0:vigra-load-rgb-image
<daviid>second, how come 155.48 0.00 ice-9/threads.scm:284:4:loop ?
<ijp>because that column is cumulative
<ijp>the last column is the important one
<daviid>ijp: I did read that but stiull could not 'read' these properly
<ijp>so you total at 310 seconds which is 5 m 10 s as expecte
<daviid>ijp but 155.48 make-srfi-4-vector does not make sence, it should be 0.5
<ijp>it might be a mistake, it says there were only two samples taken
<daviid>and then the rest of the time should be 10 or 11 sec, not 5 min...
<daviid>ok, I will just profile vigra-load-rgb-image to see
<ijp>where is the code for im-make-channels
<daviid>in idata
<daviid> http://git.savannah.gnu.org/cgit/guile-cv.git/tree/cv/idata.scm?h=devel
<ijp>if these allocations are large, could it be a gc issue?
<daviid>ijp: no, the allocation time is 0.5 sec
<ijp>have you tried precomputing all the arguments, and only timing the call to load-rgb-image
<catonano>one of the C functions I have to wrap in Guile scheme expects an "unsigned short" as an argument. How do I indicate that ? uint8 ?
<ijp>daviid: have you tried precomputing all the arguments, and only timing the call to load-rgb-image
<ijp>catonano: shorts are at least 16 bit, so probably uint16
<ijp>you'd probably need to do configuration to make it portable, idk, which is probably why the types guile supports all specify the size
<catonano>ijp: thank you !
<daviid>ijp: sorry, inadvertently tried to measure im-make-channels ... on my laptop, which literalçly killed it :)
<catonano>uhhmm nothing. I can't get it to accept a signature
<catonano>in case anyone would take a lookk at my code in order to review it briefly (I'd be grateful) it's here https://gitlab.com/humanitiesNerd/guile-freexl
<ijp>daviid: I was just saying, have you tried precomputing all the arguments, and only timing the call to load-rgb-image
<daviid>ijp: I was trying to do that, but wrong window, and my laptop does not have the capacity to hold these size, let me try, give me a sec
<catonano>ijp: what do you mean, exactly with: "you'd probably need to do configuration to make it portable" ?
<ijp>it is possible, but I have no idea how likely, that 'short' can mean different things on different computer systems
<ijp>in that case you would want to choose the type depending on the system
<ijp>this seems like something (system foreign) should be able to handle
<catonano>ah
<catonano>that maybe the case. uint8, uint16 and uint32 produce the same error: wrong argument type
<catonano>I will write on the mailing list again
<daviid>ijp: here is the result
<daviid>scheme@(guile-user)> ,profile ((@@ (cv impex) vigra-importrgbimage-c) r g b width height f)
<daviid>% cumulative self
<daviid>time seconds seconds procedure
<daviid>100.00 308.88 308.88 anon #x558100d213e8
<daviid>---
<daviid>Sample count: 1
<daviid>Total time: 308.883311234 seconds (0.0 seconds in GC)
<daviid>
<daviid>so, this is, strictly, the time spend executing the vigra_c code ... however they pretend (the vigra_c developer) loading the same image size, using this vigra-importrgbimage-c but from mathlab, takes 14sec, which I doubt, coud that be possible?
<ArneBab_>daviid: do you get the same time without ,profile?
<ijp>I don't know how, but could there be some (system foreign) overhead?
<daviid>ArneBab_: yes
<daviid>ijp: that is what I really would like to know, and happy to learn how to debug this maybe
<ArneBab_>then I could imagine that the matlab folks use some shortcuts which avoid restructuring data
<daviid>but it is what they pretend
<ijp>I can believe they might take some shortcuts, but that wouldn't explain why python is so much faster
<ArneBab_>Python is pretty good at keeping things down in C
<daviid>however, when I loada the same image but using libfreeimage (from davexunit), which also uses (system foreign), I get 0.9sec
<ArneBab_>when using numpy it effectively never leaves the C array
<ArneBab_>daviid: what kind of datastructure do you get from that call?
<daviid>ArneBab_: I allocate, 3 f32vectors of +- 350MB each
<ArneBab_>that’s what it returns? What’s the initial size of those vectors?
<daviid>ArneBab_: it does notr return anytrhing
<ArneBab_>so you pass it the vectors and it populates them?
<daviid>yes
<daviid>ArneBab_: here http://git.savannah.gnu.org/cgit/guile-cv.git/tree/cv/impex.scm?h=devel
<daviid>line 168 ... and 224
<daviid>ijp: given using libfreeimage takes 0.9sec, using the FFI as well, I take for granted that there is no over time spent in (system foreign), wdyt?
<ArneBab_>… and it just gets 4 pointers …
<ArneBab_>daviid: which flags are used to compile libvigra?
<daviid>ArneBab_: don't know, here is the tree https://github.com/BSeppke/vigra_c
<daviid>ArneBab_: all I do is: cmake -DCMAKE_INSTALL_PREFIX=/opt/vigra_c; make; make install
<ArneBab_>daviid: looks like matlab is effectively doing the same as you: https://github.com/BSeppke/vigramatlab/blob/master/loadimage.m#L23
<daviid>ArneBab_: right, and Benjamin (the author) said he profiles and it takes 14"
<ArneBab_>is it multithreaded?
<ArneBab_>can you see the CFLAGS when you execute ccmake . in vigra_c?
<daviid>ArneBab_: how can I do that?
<ArneBab_>ccmake should give you an interactive UI
<ArneBab_>cd vigra_c; ccmake .
<daviid>ok
<daviid>have to install ccmake
<ArneBab_>it doesn’t come with cmake? (the world changed…)
<daviid>ArneBab_: don't know but command not found ...
<daviid>can't find ccmake in debian
<daviid>ah, cmake-qt-gui is the package
<daviid>hum not it yet
<daviid>bash: ccmake: command not found
<daviid>
<ArneBab_>I’d first need to install vigra to make that work …
<ArneBab_>(to test it)
<daviid>ArneBab_: cmake-gui does not list CFLAGS
<daviid>is there a cmake option to just lkist the flags?
<ArneBab_>I’m not sure, checking
<ArneBab_>make VERBOSE=1
<ArneBab_>with that you can check the actual compiler calls — and see whether it uses optimization
<ArneBab_>daviid: according to stackoverflow, you can use -DCMAKE_BUILD_TYPE=RELEASE to tell cmake to optimize. https://stackoverflow.com/a/32250455/7666
<daviid>will try
<daviid>here is the first compilation 'report':
<daviid>cd /usr/local/src/vigra_c/git/src && /usr/bin/c++ -Dvigra_c_EXPORTS -I/opt2/vigra/include -fPIC -std=gnu++11 -o CMakeFiles/vigra_c.dir/vigra_convert_c.cxx.o -c /usr/local/src/vigra_c/git/src/vigra_convert_c.cxx
<daviid>
<ArneBab_>that looks like it does not use any optimization at all
<ArneBab_>I’d have expected to see at least -O2 in there
<daviid>ArneBab_: trying your D... suggestion, let'1s see
<ArneBab_>(though it should still be fast if vigra is compiled with optimization turned on)
<daviid>I don't know if vigra is compiled with optimization because I manually compiled it
<daviid>ArneBab_: now it says:
<daviid>/usr/bin/c++ -Dvigra_c_EXPORTS -I/opt2/vigra/include -O3 -DNDEBUG -fPIC -std=gnu++11 -o CMakeFiles/vigra_c.dir/vigra_convert_c.cxx.o -c /usr/local/src/vigra_c/git/src/vigra_convert_c.cxx ...
<daviid>maybe I should recompile vigra first
<ArneBab_>ah, much better. See the -O3 in there
<ArneBab_>that can make several orders of magnitude difference
<daviid>ArneBab_: thanks, I think I should recompile vigra
<ArneBab_>good luck — I hope it helps!
<daviid>let see it will only take a few minutes
<daviid>ArneBab_: unbeleivable!
<daviid>I ow you 100 beers
<daviid>scheme@(guile-user)> ,profile ((@@ (cv impex) vigra-importrgbimage-c) r g b width height f)
<daviid>% cumulative self
<daviid>time seconds seconds procedure
<daviid>100.00 4.07 4.07 anon #x55ef8f4a1c28
<daviid>
<ArneBab_>nice!
<ArneBab_>happy hacking!
<ArneBab_>daviid: you might want to use type RELWITHDEBINFO while developing
<daviid>ArneBab_: thanks but I don't develop vigra neither vigra_c, I bind these... though thanks for the tip
<ArneBab_>these are just to get good backtraces when something goes wrong
<daviid>ok