freenode/#lisp - IRC Chatlog
Search
8:07:14
phoe
On SBCL, how can I identify the thread that takes up 100% of my CPU if I have several worker threads?
8:09:33
phoe
Yes, sure, but that will not give me the thread name assigned to it by BORDEAUX-THREADS, will it?
8:10:09
phoe
I can see the thread in top or htop, no problem, but I want to identify *which* one it was, and what it was doing.
8:14:26
fourier
in c/c++/java etc ides you can just hit pause in debugger and investigate what your threads are doing. not sure how can you do it in CL other than logging
8:14:28
beach
It's an interesting point though. Any sophisticated Common Lisp debugger must be able to help in such situations.
8:14:52
phoe
I have a hash-table from thread objects to descriptions of the tasks that they are doing now.
8:19:48
beach
fourier: I know. It is even fair to say that no free Common Lisp system even has a debugger worthy of that name.
8:23:26
fourier
I find the general debugging in CL troublesome process. due to the nature of different rules like (if condition statement1 statement2) its not easy to add logging real quick - since I would have to add progn as well. also general unavailability of the nice stepper is a problem - the same with (break) - I have to modify my code and insteart progn there as well
8:24:28
fourier
the only nice debugging tool which fit the bill I found is Stepper in LW - and it was one of the reasons I've purchased it since it made my life so much easier
8:27:41
fourier
if you can record a simple debugging session with it and place on youtube/animated gif/etc I can take a look and tell the difference/similarities
8:29:47
jackdaniel
can anyone successfully call (ql:quickload 'clml) ;? I have a problem with loading package on sbcl
8:34:38
phoe
I could theoretically make a function that repeatedly calls (interrupt-thread thread #'break) on all thread objects, also printing them out for me. And I can watch when the CPU goes down.
8:35:07
phoe
Like, calls #'BREAK consecutively on the next thread when I continue in the current one.
8:35:09
smokeink
fourier: here are some gifs http://malisper.me/debugging-lisp-part-1-recompilation/ "When Tom tries to calculate the tenth Fibonacci with this code, a debugger window pops up because an error was signaled." ...
8:35:10
jackdaniel
OK, I get it – clml depends on some system which is internal to it, but this system is not declared in ql dist
8:35:54
jackdaniel
it may be solved by quickloading clml.utils first (then tgz is downloaded and missing system is found)
8:37:20
fourier
smokeink: I see. this is exactly what I dont like as I said - I want to have a "break" at any statement, and insterting manually (break) doesn't cut it - since it would force me to add progn for single-expression statements
8:38:00
fourier
while in LW I can just set breakpoint at any statement and then it will be hit the stepper will be popped out
8:39:36
smokeink
I was thinking of coding a reader macro called bp! or something, that can be inserted anywhere and that does the progn wrapping and everything automatically
8:40:00
fourier
LW also has a process browser to see which threads are running, so in general its IDE really helps with debugging
8:43:29
smokeink
and one can set a breakpoint keybinding in emacs and have this 'set breakpoint' functionality similar to the one in lispworks. Next, we need the view threads functionality . Doesn't slime have something for threads? slime is not useful for this particular threads issue you're experiencing now phoe?
8:53:16
smokeink
sb-thread:*current-thread* <- what are os-thread and primitive-thread slots in this structure ?
8:53:23
fourier
as soon as you able to get native pid from thread object, all you would need to do is to iterate over all thread objects to find the proper thread object
8:58:35
smokeink
http://ask.xmodulo.com/view-threads-process-linux.html check out this "Show custom thread names" htop screenshot
8:59:42
fourier
no i dont think so, pthreads doesnt seem to have thread names, I guess these names are sbcl-only
9:12:02
smokeink
yeah same here... hmm what's this https://github.com/sile/taomp-sbcl/blob/master/thread-id.lisp
9:14:30
phoe
and the list of all threads can change at any time, even before the list-all-threads function returns.
9:44:41
smokeink
phoe: I think a solution is to syscall from within sbcl https://stackoverflow.com/questions/19350212/which-linux-syscall-is-used-to-get-a-threads-id using (sb-unix::syscal
9:45:27
smokeink
but I haven't figured out yet how to do that... the syscall examples here are all for Win32api https://searchcode.com/file/5603613/src/code/unix.lisp
9:47:50
phoe
I'll pause this question for now. I'll just break all threads until I see a decrease in CPU usage.
9:49:13
smokeink
I think the TID should be one of the numbers in the TID column this output: ps -To pid,tid -p `pidof sbcl`
9:50:12
smokeink
if not, then it should still be possible to obtain a mapping from the 'crazy number' to the number used by the OS
9:56:03
smokeink
(sb-alien:alien-funcall (sb-alien:extern-alien "getpid" (function sb-alien:unsigned)) ) ; getting close
10:06:48
smokeink
phoe: try this: (sb-alien:alien-funcall (sb-alien:extern-alien "syscall" (function sb-alien:unsigned int )) 224)
10:15:59
smokeink
okay, then you must be using a different system. On my system it works perfectly. Find the gettid syscall code for your system and replace that 224 with it
10:27:10
smokeink
I have no idea.. :) but I think under the hood syscalls are always happening from within the thread
10:30:15
phoe
I can't execute the syscall from outside the thread because it will give me the PID of the thread that executed the syscall.
10:31:15
phoe
Unless we patch SBCL, so it executes that syscall on thread creation and puts its return value inside a new slot in the THREAD structure.
10:31:49
phoe
Which in turn generates issues for multiplatform support, because either it'll be Linux only and therefore ugly, or we do the same for all other platforms that it supports.
10:32:00
smokeink
can you patch the running thread ? and tell it to push its id and its thread-object into some list ?
10:35:51
smokeink
just a random thought: is that thread making the machine run slow? Is it possible to change the priority of a thread and observe whether the machine got faster or not? if so, maybe playing with priorities is a way to find which of the threads is the culprit
10:36:19
phoe
If I go this way, I can (interrupt-thread thread #'break) and see if the CPU usage goes down from 100% to 0%.
11:16:27
smokeink
https://stackoverflow.com/questions/28948415/get-thread-id-in-sbcl/48972801#48972801
11:50:28
smokeink
phoe: that wine/ntdll/server.c get_unix_tid() code is nice. I updated the stackoverflow answer with a get-thread-id that works on windows
11:50:30
Xach
phoe: ironclad's functions are deeply interlinked into a framework. hard to isolate just what you need.
12:00:07
smokeink
phoe: turns out that for Windows a 1 liner is also possible: (sb-alien:alien-funcall (sb-alien:extern-alien "GetCurrentThreadId" (function sb-alien:unsigned)))
12:41:06
scymtym_
C-c C-d d describes the object at point. for symbols, the description usually includes the docstring. this is not automatic, of course. C-c C-d ? lists a bunch of useful functions
12:43:55
oruppert
It would be nice to see not only the argument list in the emacs message area, but also the first line of the docstring.
13:13:06
smokeink
<smokeink> Let's say I have this fib function that breaks when the parameter n equals 2 , https://stackoverflow.com/questions/27889989/stepping-in-sbcl-from-within-the-debugger?rq=1 How to proceed to STEPPING , right after the (break) , without using slime's Return From Frame" (R) and manually typing (fib 2) ? <beach> You probably can't, depending on the Common Lisp implementation you are using.
13:13:16
smokeink
beach: with sbcl and slime, one can just press s after the break took place :) and it will go into stepping mode
13:26:36
Baggers
Is there a reliable way to check if a potential type specifier is valid? I have no use for this just curious. Closest I got was this horrible thing (handler-case (nth-value 1 (subtypep x nil)) (error ())) where x is the specifier
13:26:54
Colleen
Bike: Shinmera said 4 hours, 42 minutes ago: The CCS stuff is not just metadata. It should be visible in the document. The ccsxml should be in the header https://github.com/Shinmera/talks/blob/master/els2018-glsl-oop/paper.tex#L31-L59 and after the abstract should be \printccsdesc https://github.com/Shinmera/talks/blob/master/els2018-glsl-oop/paper.tex#L85
13:50:46
Xach
Baggers: did you update cepl re formatter issue? I wasn't sure on which end it got fixed...
13:51:53
Shinmera
Xach: maybe both. https://github.com/Shinmera/documentation-utils/issues/4#issuecomment-368309280
13:54:44
burton`
If I have a (handler-case .... (error (e) (print e))) form, how do I get the actual error string from the condition 'e', rather than a non-readable representation of the error?
15:56:44
jmercouris
I saw that post on reddit about Lush, and it had me thinking, are there any usable shells written in lisp?
15:58:34
Shinmera
I recall hearing of multiple such projects, but they never really took off because Lisp is a bit verbose for scripting.
16:02:06
jmercouris
I guess it's all relative, I was never good at shell scripting, so I've not had this "succinct" experience
16:02:28
jmercouris
You could ship the shell with a set of macros that make operations like that easier
16:03:34
beach
jmercouris: Oh, you want the syntax to be just like sh or bash, but you want it written in Common Lisp?
16:03:35
jmercouris
What I think would be cool though would be that your "shell scripts" could be written in lisp
16:04:14
Xach
jmercouris: rob warnock wrote about his "OPFR" syntax on comp.lang.lisp from time to time. it was interesting to me.
16:06:00
Shinmera
You can put #!/whatever/dude at the top of a file and the shell will call that executable with the file.