Re: What causes the text that I print to the terminal to become mangled garbage?
There *is* mutual exclusion on all Java output streams (as well as input streams) so at least individual prints should be atomic. Not that it will solve this, but still, this kind of granularity of interleaving is unusual. I have never seen it. On Wednesday, March 13, 2013 4:27:00 AM UTC+1, Michael Klishin wrote: 2013/3/13 larry google groups lawrenc...@gmail.com javascript: At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread If your app itself prints stuff to stdout/stderr, it is likely to be interleaved with the output from the spying thread. Thread execution order and time slicing is non-deterministic and nothing synchronizes writing to stdout/stderr to enforce ordering. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: What causes the text that I print to the terminal to become mangled garbage?
Thanks all. I don't think this can be just a concurrency issue or I would also see it when I'm not using Timbre. If I call pprint from multiple threads I don't get this kind of interleaving of individual characters. Nor do I normally get this interleaving when just using Timbre. But somehow the combination of thread-measuring functions and Timbre set off some fireworks. Maybe I'll dig into this when I have more time. For now I've switched to simple println (rather than Timbre) statements for the thread-measuring stuff. On Wednesday, March 13, 2013 4:02:59 AM UTC-4, Marko Topolnik wrote: There *is* mutual exclusion on all Java output streams (as well as input streams) so at least individual prints should be atomic. Not that it will solve this, but still, this kind of granularity of interleaving is unusual. I have never seen it. On Wednesday, March 13, 2013 4:27:00 AM UTC+1, Michael Klishin wrote: 2013/3/13 larry google groups lawrenc...@gmail.com At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread If your app itself prints stuff to stdout/stderr, it is likely to be interleaved with the output from the spying thread. Thread execution order and time slicing is non-deterministic and nothing synchronizes writing to stdout/stderr to enforce ordering. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: What causes the text that I print to the terminal to become mangled garbage?
tl;dr concurrency is hard Jason, if it was just a concurrency issue, it would happen when I use pprint. But the above mess only seems to happen with a very specific combination of Timbre and thread measuring functions. On Wednesday, March 13, 2013 12:16:46 AM UTC-4, Jason Lewis wrote: tl;dr concurrency is hard Jason Lewis Email jasonl...@gmail.com javascript: Twitter@canweriotnow http://twitter.com/canweriotnow Blog http://decomplecting.org About http://about.me/jason.lewis On Tue, Mar 12, 2013 at 11:27 PM, Michael Klishin michael@gmail.comjavascript: wrote: 2013/3/13 larry google groups lawrenc...@gmail.com javascript: At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread If your app itself prints stuff to stdout/stderr, it is likely to be interleaved with the output from the spying thread. Thread execution order and time slicing is non-deterministic and nothing synchronizes writing to stdout/stderr to enforce ordering. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: What causes the text that I print to the terminal to become mangled garbage?
pprint uses refs internally rather than vars. I was always a bit suspicious about that... Perhaps transaction retries are happening? On Wed, Mar 13, 2013 at 3:19 PM, larry google groups lawrencecloj...@gmail.com wrote: tl;dr concurrency is hard Jason, if it was just a concurrency issue, it would happen when I use pprint. But the above mess only seems to happen with a very specific combination of Timbre and thread measuring functions. On Wednesday, March 13, 2013 12:16:46 AM UTC-4, Jason Lewis wrote: tl;dr concurrency is hard Jason Lewis Email jasonl...@gmail.com Twitter@canweriotnow http://twitter.com/canweriotnow Blog http://decomplecting.org About http://about.me/jason.lewis On Tue, Mar 12, 2013 at 11:27 PM, Michael Klishin michael@gmail.comwrote: 2013/3/13 larry google groups lawrenc...@gmail.com At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread If your app itself prints stuff to stdout/stderr, it is likely to be interleaved with the output from the spying thread. Thread execution order and time slicing is non-deterministic and nothing synchronizes writing to stdout/stderr to enforce ordering. -- MK http://github.com/**michaelklishin http://github.com/michaelklishin http://twitter.com/**michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@**googlegroups.com For more options, visit this group at http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
What causes the text that I print to the terminal to become mangled garbage?
I saw some functions here that measure CPU and thread usage: http://lifeisagraph.com/2011/04/24/debugging-clojure.html That looked good, so I imported them into my app. I've done this before and not had a problem with it. For logging, I like to use the Timbre library: https://github.com/ptaoussanis/timbre And then I thought I should call the thread-measuring function and hand its return value to timbre. And suddenly the info that I'm logging to the terminal became a mangled mess of strangely intermingled text. Can anyone suggest why this is happening? ((applyapply str at the start of persistrst-sessi on -data-to-databaseop,t io ouarnt cvtpaluhu eea =nsd'tt athrehtar teoeafrd 'deTlh eetaete-urol/do-pssteioanssiogns , eour c pu alnd thoreado usagke losoks l liikeke this:t his : option value='music'Music/option(debug/thread-top)) (debug/thread-top) ) [ at the[ start of adeleoptteio-no vladlu-es='easlsl-ikoinndss,' Aolulr ki ndcsp/to pttihone ]s]ta rt of peu2013-Mar-12 23:03:21 -0400 MacBook-Pro.local DEBUG [kiosks-clojure.core] - in get-options-for-select-box: [option v\ alue='dance'Dance/option option value='theater'Theater/option option value='music'Music/option option value='all-kinds'\ All kinds/option] r sainstd- thsreesasdi ouns-adgaet al-oto2ok0-s1d 3l-iMkaer a-tt1ah2ib sa2:s3 e:[,03 31o:u42412 7-7r00 4 c \pLua wDarenesdnt crteohs\ yr-JeMaaavcdaB ouVosMka\ge 2l2o o#k-TPhrroe.aldo s clailk eD EtBhUiGs :[ k[i3o1s4k4Ts2h-7rce7la0od0j[uDrees.tcrooryeJ]ava VM,05 ,\maiDne]st]ro[4y7Ja3i1vna6V0 0Mg0\e t\- 2o2p t#ioTnhsr-efaodrT -hTsrheerlaedc-t1-1b\ox: 19 #Thea[dr[[eDaeds tTrhoryeJada[vToaphrtVeiMoa,nd5- ,1vm1aa,luien=]'d]a[n4c6e0'210D0a0n c\e/Tohprteiaodn-11\ 19 #Thr5e,maadin] ]\ T[h3r0e8a9d4[0T0h0r e\ad-T1h1r,ead-12\ 20 #Thread Thread[Th r ead-12,5,main]][51,3m4a2i7n0]00] [3\0894000 \Thread-12\Tohread- 1230\ # 2Th1 re#aTd hTrehared aTdh[rTehad[Tread-12,5,main]][\ 1340 \hread-13,5,maiTnh]re]a[96 d\-13q\tp5 2211 8#89pT0thi0or5ne-a1 dv1a lTuSehe=rl'teehaceadtt[oerTr'hrTheeaadte-r13/,op5\ t,imonain] ] [96\0 \q t1p15 2#18T8h9r0e0a5d- 1T1h rSeealde[cqtotrp052\18 81910 0#5-T1h1r Seealde Tchtroera0d,[5q,tpm5a2i1n8]89]0[0854-9101\ 0S0e l\ectqort0p,55,main]][849000 \qtp52121889080859-01035 -A1c3ce pAtcocre0pt oSer0l ecSteClehcatnCnehalnConnenleCoctnnore@c0t.oo0r\ p.@t0i0o..n0 0:v.a3l00u.e00=0':1m3u\s0i0c0'1M\usic 1/3o pt# io1nT3h r#ea At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread, repeating endlessly: (defn persist-session-data-to-database [] (timbre/spy :debug (apply str at the start of persist-session-data-to-database, our cpu and thread usage looks like this: (debug/thread-top))) (try (let [documents-to-be-persisted (get-data-to-be-persisted)] (doseq [[k v] documents-to-be-persisted] (monger/persist-document-to-database (add-key-to-document k v (catch Exception e (debug/print-error-info e))) (timbre/spy :debug (apply str at the end of persist-session-data-to-database, our cpu and thread usage looks like this: (debug/thread-top))) (. java.lang.Thread sleep 60) (persist-session-data-to-database)) -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: What causes the text that I print to the terminal to become mangled garbage?
tl;dr concurrency is hard Jason Lewis Email jasonlewi...@gmail.com Twitter@canweriotnow http://twitter.com/canweriotnow Blog http://decomplecting.org About http://about.me/jason.lewis On Tue, Mar 12, 2013 at 11:27 PM, Michael Klishin michael.s.klis...@gmail.com wrote: 2013/3/13 larry google groups lawrencecloj...@gmail.com At least some of this mangled text is coming from this function, which is called at startup and then runs in its own thread If your app itself prints stuff to stdout/stderr, it is likely to be interleaved with the output from the spying thread. Thread execution order and time slicing is non-deterministic and nothing synchronizes writing to stdout/stderr to enforce ordering. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.