IRC channel logs

2014-11-30.log

back to list of logs

***u_l-lap is now known as unknown_lamer
<cky>Yes, I finally have a build of Guile on OS X (10.10 Yosemite), building with Xcode 6.1's clang, that passes the test suite.
<cky>If you build it with default options, it will blow up in srfi-18.test.
<cky>I should submit a patch on the mailing list and ask other Xcode users to verify whether the patch works for them.
<taylanub>cky: if you want you can remind me tomorrow at around these times and I'll see if I can test it too, with Xcode 6.1 on OS X 10.9.
<taylanub>(have OS X at work)
<davexunit>does anyone know of a good way to go about hunting for a memory leak in a guile program?
<jmd>davexunit: As I understood it there is no such thing. It has a garbage collector.
<davexunit>jmd: memory leaks are still possible in GC'd languages.
<davexunit>and I created one. :)
<jmd>But surely only if the GC is not working ?
<davexunit>thing is, I knew about the potential for leakage so I thought I had written my code such that the leak wouldn't happen.
<davexunit>jmd: still possible.
<davexunit>I've gotten myself in a situation where the GC cannot free the memory
<davexunit>because it is in fact still referenced somewhere, but it's unusable to me.
<davexunit>the dangers of doubly linked structures. :)
<davexunit>and the dangers of a runaway coroutine.
<davexunit>I found the culprit, but I'm not sure why this coroutine seems to be eating 1MB/s and never letting it go.
<ijp>constipation
<davexunit>ijp: hehe
<davexunit>something about this weak key hash table I'm using...
<davexunit>I hope this is me being an idiot and not a guile bug
<civodul>Hello Guilers!
<davexunit>hey civodul
*davexunit thinks he found the source of the memory leak. font rendering! gah!
<civodul>a leak in Sly?
<davexunit>yup
<davexunit>my game of 2048 got real slow and I was using a half GB of RAM!
<davexunit>and it's because I did a bad thing: not using my existing code for creating textures when rendering text.
<davexunit>I wrote a finalizer that will delete GC'd textures from OpenGL's state.
<davexunit>but, since I didn't use that existing code, I was creating textures with no finalizer. :(
<civodul>ouch, i see :-)
<davexunit>a little refactoring will save me. :)
<davexunit>I got over a big hurdle yesterday, if I fix this and there are no other blocker bugs, Sly 0.1 won't be too far away anymore.
<civodul>yay!
<davexunit>(then I can get back to guix hacking ;)
<civodul>heh
<paroneayea>hey guilers
<amirouche>héllo too :)
<davexunit>hey paroneayea
<paroneayea>hey davexunit
<paroneayea>I'm having fun considering some crazy refactoring in mediagoblin
<davexunit>yay refactoring
<davexunit>I'm refactoring without changing public APIs, woo! (not that it matters for an unreleased project)
<paroneayea>:)
<paroneayea>I'm trying to get rid of our global variable context stuff which pains us so
<paroneayea>but... it requires changing things to pass around a context object pretty much everywhere
<paroneayea>which will be... a big change.
<davexunit>time for a mediagoblin monad!
<davexunit>a monadgoblin
<amirouche>that's what I doo too in my web app
<paroneayea>davexunit: yeah, I don't know enough about monads
<davexunit>in scheme, sometimes we use 'parameters', thread-local dynamic variables, for this stuff
<paroneayea> http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax.html I could tyr reading this
<paroneayea>davexunit: right, python *kind of* has this, but it isn't really sufficient
<davexunit>a monad in python might not be the best idea, but I wanted to say monadgoblin.
<paroneayea>it doesn't work once you go down the asyncio/twisted route
*davexunit nods
<paroneayea>because that's non-blocking "async" stuff all happening in a single thread
<paroneayea>so a coroutine might suspend, then wake up later
<paroneayea>and oh no, the thread's context changed!
<davexunit>I think guile's parameters would continue to work as expected.
<davexunit>the dynamic extent of the parameter is captured.
<davexunit>but maybe I'm not understanding you. :)
<paroneayea>davexunit: consider:
<davexunit>but yeah, some way to avoid passing a context object along everywhere is desirable.
<davexunit>the only ways I know are parameters and monads.
<davexunit>and of course globals.
<paroneayea>view1(request):
<paroneayea> result = yield from thread_globals.db.session(query="foo")
<paroneayea> return Response(
<paroneayea> thread_globals.gettext_thing(
<paroneayea> "I am translating in the right language, and you wanted " +
<paroneayea> result))
<paroneayea>
<paroneayea>view2(request):
<paroneayea> return Response("Yeah whatever man")
<paroneayea>so two views/controllers.. the first one suspends becuse it's doing a db request
<paroneayea>being queried by a user in french
<paroneayea>I messed up the gettext thing, the + should happen outside it
<paroneayea>but whatever
<paroneayea>the second user is in english
<paroneayea>while the first one is suspended waiting on the db query response, the english one happens
<paroneayea>the thread global switches to english
<paroneayea>view1 wakes back up, bam, wrong language
<davexunit>yeah, guile's parameters wouldn't have that issue :)
<paroneayea>:)
<davexunit>they're like emacs dynamic scope
<davexunit>so when that async routine wakes up, the value of the parameter is still what you had set for it.
<davexunit>I dunno how to do it in python.
<paroneayea>there's no such thing I know of in python
<paroneayea>I would say "hey closures" but actually I don't think there's a nice way to do that with closures in python
<paroneayea>though...
<paroneayea>maybe you could with decorators, but I'm not so sure
<paroneayea>I'd like to learn monads but I really don't know where to begin :(
<paroneayea>every time I look into it I get confused
<davexunit>it's certainly confusing
<davexunit>I learned enough to use store monad in guix to write something
<davexunit>use the*
<davexunit>thought I fixed my memory leak, but no :(
<paroneayea>davexunit: the thing I think here though is that for most of the code, there's already a ~context object being passed through things
<paroneayea>the request!
<amirouche>paroneayea: why isn't the language attached to the request?
<paroneayea>so I use that as a general attachment of different parameters, but if it's not a web request but some other task
<paroneayea>I attach everything to a super basic Context object that's just there to get stuff stuck to it
<paroneayea>so many of the functions still work
<paroneayea>amirouche: it is
<davexunit>paroneayea: oh, well that's good.
<paroneayea>amirouche: but our current code doesn't use that
<davexunit>you don't have to fix everything then
<paroneayea>it does gettext()
<paroneayea>no parameter passed in
<paroneayea>davexunit: I have to fix less :)
<paroneayea>there's a lot of stuff we did to make the ORM easy to use from everywhere
<paroneayea>by looking for a global session
<paroneayea>so all the code everywhere seems to need some updates ;)
<davexunit>ahhhh
<davexunit>I see
<paroneayea>lots of things relied on mg_globals, which is "thread safe", but
<amirouche>then you should be able to change the current langage when you yield
<amirouche>Flask has a similar problem, since "request" is a thread local global.
<paroneayea>amirouche: well, we're not using yield yet, since this is more dumb previous generation django-style programming, but I want to move things over to asyncio in the future
<paroneayea>and we have other problems now
<paroneayea>yes, flask has the same problem,
<paroneayea>and changing on yield is not so easy / possible
<paroneayea>the best option is to take advantage of the current asyncio Task object and attach stuff to that
<paroneayea>but it's extremely flaky
<paroneayea>I am writing a program that *is* using asyncio though
<paroneayea>aiohttp and aiopg
<paroneayea>it's not released yet... I'm mostly using it to figure this stuff out, but eventually hopefully it'll be a low-level implementation of the federation standard being written by the w3c socialwg
<paroneayea>(I've thought of writing a guile version but it's more useful for me to write it in python for learning stuff for mediagoblin reasons)
<paroneayea>and I'm still pretty slow at guile ;p
<amirouche>(to change things on yield you will probably need to tweak the eventloop)
<ijp>all you need to know about monads is you almost certainly don't need them
<davexunit>:P
<ijp>and if you do, you've probably invented tehm already
<paroneayea>I think the closest to a monad thing I could do
<paroneayea>is start wrapping functions so the context object is invisible as part of a closure
<paroneayea>but even if I did that I'd still be passing the context object in as first argument, it just wouldn't be seen in the function
<paroneayea>doesn't seem like a big benefit
<alandipert>do any other languages target the guile vm?
<ijp>alandipert: the elisp is probably the most mature. the js and lua are kinda meh. no idea about stis' prolog
<alandipert>oh, prolog is exciting. i’m just exploring, toy stuff would be fun to look at too
<ijp>occasionally someone talks about python, but I don't know if it went anywhere
*davexunit fixed the memory leak
<davexunit>(wasn't using finalizers for opengl vertex buffers and vertex arrays)
<davexunit>oops!
<jmd> http://lists.gnu.org/archive/html/bug-guile/ says the archives are refreshed every 30mins. My post from 3 hours ago is not listed.
<sg2002>Have a question, in guile 1.8.7, I get that there's no "unquote" function. Was it supposed to be there? Or it's in some lib, that I haven't required?
<ijp>unquote isn't a function, it's basically subsyntax of quasiquote
<jmd>sg2002: But it does have , I think.
<sg2002>jmd: Is there some other syntax for it apart from (unquote ?
<jmd>,
<sg2002>jmd: Ok, that's weird. My interpreter understands that "," is unquote, but still can't find it.
<ijp>sg2002: what are you actually trying?
<amirouche>sg2002: I tried http://dpaste.com/35JX0GD, it looks like guile doesn't know about (unquote ...) outside a (quasiquote ...)
<ijp>because it makes no sense outside of a quasiquote
<ijp>in 2.x at the repl it serves a slightly different function for repl commands, which it didn't in 1.8.x
<sg2002>ijp: My lilypond script grew to the point it needs some testing framework and since there seems to be no unit test module for guile that old, I'm trying to make it work with org-babel. But when babel is ran through geiser, geiser sends unquote to guile and this of course does not work.
<ijp>right, the problem then is that 1.8.x doesn't have repl commands
<ijp>so you can't really use geiser for it
<sg2002>ijp: Just thinking of a dirty hack to fix this.
<sg2002>ijp: I actually use geiser with it. Normally. But through org babel is does not work.
<ijp>that is surprising
<sg2002>ijp: Yeah, especially since geiser explicitly does not support guile < 2.0.
<sg2002>amirouche: Ok, quasiquote works in that version, so now I know what to "fix". Thanks.
<amirouche>I've been looking around for bugs for 30 minutes... the algorithm was ok... if only I did not mistype things
<amirouche>looks like working with hashtables is not the best idea
<amirouche>I found a funny procedure that I called continue-until-true, it allowed me do break down the algorithm much more readble (imo) http://dpaste.com/3YXW3DZ#line-11
<cky>taylanub: I won't be awake at 11:15 UTC, usually (it's 06:15 Eastern Time), unless I get woken up by my cat. But I'll see what I can do.
<taylanub>:)
<taylanub>cky: you can tell me a couple hours earlier (like when you had initially written that line) and I'll see it later :P
<cky>taylanub: Okay, I'll ping you before I go to sleep.
<taylanub>heh, ok
<civodul>ijp: you were working on a JS compiler back-end, no?
<sg2002>Kind of a newbish question - what would be the most idiomatic way to search list for any elements that are not equal to the element specified. Need only the first element.
<civodul>(find (cut equal? <> the-thing) lst)
<civodul>using SRFI-1 and SRFI-26
<davexunit>(find (negate (cut equal? <> the-thing)) lst) ;; get the first thing that isn't equal
<civodul>oh right
<davexunit>(find (negate (lambda (x) (equal? x the-thing))) lst) ;; without cut
<ijp>if you were going to get rid of cut, I'd also get rid of negate
<davexunit>ijp: fair point. :)
<ijp>civodul: I just haven't had the time to make any real headway
<civodul>ijp: okay, was wondering
<civodul>i may have to do web stuff again at work
<civodul>and i cannot endorse HOP nor JS ;-)
<civodul>but HOP is conceptually what i'd like to have
<davexunit>how does get the modulo of 2 rational numbers in guile?
<davexunit>I can't find a built-in procedure, but I could be missing it.
<ijp>hmm, what a weird thing to do
<davexunit>I'm trying to write a function that loops over a range.
<davexunit>in this case [0, 1)
<ijp>cross multiply, take the mod, then divide through?
<ijp>(define (mod-rat x y) (/ (modulo (* (numerator x) (denominator y)) (* (denominator x) (numerator y))) (denominator x)))
<ijp>I suspect this fails horribly somehow for negatives
<davexunit>just found something that does the trick
<ijp>whoops, that code is wrong anyway
<davexunit>it's intended for floats, but of course works just fine here
<davexunit>(define (fmod x y) (- x (* (floor (/ x y)) y)))
<davexunit>fmod is a bad name, but that's what it's called for floats.
<davexunit>make sense.
<ijp>(fwiw, it should have divided by both denominators)
<ijp>(and yes, it does fail for negatives)
<davexunit>you reminder me of the existence of the numerator and denominator procedures.
<davexunit>reminded*
<ijp>where fail here means not giving a number between 0 and abs(denom)