IRC channel logs

2025-07-13.log

back to list of logs

<cow_2001>siiiiiggghhhh https://forum.systemcrafters.net/t/how-do-you-profile-a-certain-bit-of-a-gnu-guile-program-while-it-is-running/1715
<Kolev>daviid, I was wondering if there are any Adwaita apps written in Guile yet.
<robin>cow_2001, statprof may be what you're looking for (statistical profile, can also count procedure calls) https://www.gnu.org/software/guile/manual/html_node/Statprof.html
<robin>cow_2001, i usually use it to profile execution of a thunk, but for a single procedure you can use statprof-begin/statprof-end around the particular region(s) to profile (iirc it will combine profiling results until statprof-reset is called)
<robin>statprof-start and statprof-stop, rather
<robin>(and (statprof-display [port]) to print the results)
<AwesomeAdam54321>sneek: later tell rekado: Can you fix the service-name bug for guile-irc? The changes made in https://github.com/rekado/guile-irc/pull/3 work for me (using the ngircd packaged in Guix)
<sneek>Got it.
<sibl>how can I exit my process from sigaction ? I tried to add (exit 1) in my handler (SIGINT) but it doesnt exit
<sibl>this is how I setup the handler `(sigaction SIGINT (lambda (sig) (format #t "\rBye !~%") (exit 1)))`
<cow_2001>robin: says "no samples recorded"
<cow_2001>(define (f blah) (statprof-start) (let ((result (some-operation blah))) (statprof-stop) result)) and somewhere else, after calling (f blah), i (statprof-display) and it displays that
<identity>cow_2001: it means that not enough stuff happened between (statprof-start) and (statprof-stop), try running (f blah) in a loop wrapped in (statprof-start) and (statprof-stop)
<identity>or make blah bigger if you can
<ArneBab>cow_2001: I tend to statprof with ,profile (let loop ((n 10000)) <the code> (unless (zero? n) (loop (1- n)))))
<cow_2001>hmm
<cow_2001>when you put a bit of code between those two, and then call that bit of code several times, shouldn't it add more data to the statistics each iteration?
<cow_2001>like (let loop ((n 10000)) (statprof-start) (f blah) (statprof-stop) (unless (zero? n) (loop (1- n))))?
<cow_2001>hmm
<cow_2001>no, doesn't work
<cow_2001>no samples recorded even in a many times loop
<cow_2001>oops
<cow_2001>nevermind
<cow_2001>forgot to actually call loop ~_~
<cow_2001>so... %after-gc-thunk is on top
<cow_2001>reading https://dthompson.us/posts/optimizing-guile-scheme.html
<ArneBab>cow_2001: gc stuff is pretty hard to optimize for me. But they can give massive gains.
<ArneBab>⇒ good luck with the optimization!
<ArneBab>sneek: later tell dthompson: is there a chance that you could add your optimizing post to the guile reference manual?
<sneek>Okay.
<graywolf>Hello :) How do I profile a syntax-case? I wrote a syntax wrapper to args-fold from SRFI-37, and while it works, it is horrendously slow (~0.30 seconds with 490 options). By commenting out the entry point, I confirmed that basically all the time is spent before it. So during loading (I think, not sure about the phases) of the module. Now my question is, how do I debug why is it slow? In
<graywolf>general, how does how debug performance problems with syntax transformers?
<graywolf>So, ugh, any idea why `guile -L . -C . -s test.scm' does not load test.go file?
<graywolf>And how I can force it to do so?
<mwette>graywolf: You could code up your own profiler using the vm-hooks. Say, in (vm-exec-hook! (lambda () (when count (set! counter (1+ counter))))) where counter is global.
<mwette>That would not measure time, but number of vm instructions.
<ArneBab>graywolf: -s test.scm explicitly says, read the test.scm file, I think.
<ArneBab>graywolf: could you try creating a module with a (main args) procedure and then use guile -L . -C . -e '(test)'?
<graywolf>ArneBab: with -e the main is executed, but I get the repl after that. I need to do -e '(@@ (test) main)' -c '' , which is bit convoluted.
<graywolf>Additionally I need to export the `main', otherwise compiler seems to remove the definition :/
<graywolf>Hm
<graywolf>It does load test.scm.go.
<graywolf>I wonder what a shebang for Guile is supposed to look like. exec guile -e '(@ (test) main)' -s "$0" "$@" does not load the compiled version. However if I replace the -s wit -c '', the (car (command-line)) is wrong. What do people typically use?
<graywolf>I based it on https://www.gnu.org/software/guile/manual/guile.html#Scripting-Examples-1 , but that uses the -s as well.
<ArneBab>graywolf: that’s what I usually do (-c ''), yes. It’s what I found to be the fastest way to run code from a script.
<graywolf>Aaah I see, it is problem only when the executable file has .scm extension. If I name the file just `test', the `test.go' is picked up correctly.
<ArneBab>graywolf: I use https://www.draketo.de/software/guile-snippets.html#minimal-startup-time
<graywolf>When it is `test.scm', it looks for `test.scm.go'.
<ArneBab>-e '(test)' is a shorthand for - '(@ (test) main)'
<ArneBab>s/-/-e/
<graywolf>ArneBab: I admit I do not understand how the -e '(hello-world)' works.
<graywolf>Ooooh
<graywolf>Is that documented somewhere?
<graywolf>(As in, can I assume it will stay that way?)
<graywolf>It is, sorry
<graywolf>I see it now
<graywolf>Ok, and you solve the $0 by -a to exec.
<ArneBab>yes -- that requires an GNU exec.
<graywolf>Hm. Well I guess I do not *actually* care about $0 in most of my scripts, so I might be fine without that. Thanks for the help (and the link), very useful :)
<ArneBab>graywolf: the -e '(main)' has been included for ages, but only got documented when I added the documentation a few years back :-)
<graywolf>^_^
<ArneBab>graywolf: I’m glad it helps!
<ArneBab>There’s far too much stuff that’s possible with Guile but hard to find.
<ArneBab>I’m trying to fix part of that with https://www.draketo.de/software/programming-schemehttps://www.draketo.de/software/programming-scheme.pdf
<graywolf>Uff, long read :)
<ArneBab>intended a quick start into programming from nothing to best practices I found -- kind of like a tutorial.
<ArneBab>64 pages A6
<ArneBab>(it’s actually a pretty small book that fits in the backpocket)
<ArneBab>Still needs a last round of polishing before I can put it live as printed book.
<graywolf>Need to go but one last question, I guess this requires the scripts to have .scm extension to be loadable by the module lookup, correct? The best way to get the non-.scm version working, would probably be a symlink?
<ArneBab>You can use -x .EXT (I use -x .w)
<ArneBab>then it searches .EXT files (.w files), too.