Re: ANN: ClojureScript 0.0-2341, Improved Analysis & Transducers

2014-09-23 Thread David Nolen
Those are errors in core.async already fixed in master.

On Tuesday, September 23, 2014, Denis Johnson 
wrote:

> Thanks for the update.
>
> Both the previous and this causes the following warnings with core.async:
>
> WARNING: Use of undeclared Var cljs.core.async/do-alts at line 62
> file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async/impl/ioc_helpers.cljs
> WARNING: Bad method signature in protocol implementation impl/Handler
> lock-id at line 719
> file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs
> WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at
> line 722
> file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs
> WARNING: Bad method signature in protocol implementation impl/Handler
> lock-id at line 719 run/compiled/demo/cljs/core/async.cljs
> WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at
> line 722 run/compiled/demo/cljs/core/async.cljs
>
> Cheers Denis
>
>
> On Friday, September 19, 2014 5:27:28 AM UTC+10, David Nolen wrote:
>>
>> I just cut 0.0-2342, the only change is a updated dependency on
>> tools.reader 0.8.9 - this fixes an issue where source metadata would
>> leave into the runtime.
>>
>> David
>>
>> On Thu, Sep 18, 2014 at 8:23 AM, David Nolen 
>> wrote:
>> > ClojureScript, the Clojure compiler that emits JavaScript source code.
>> >
>> > README and source code: https://github.com/clojure/clojurescript
>> >
>> > New release version: 0.0-2341
>> >
>> > Leiningen dependency information:
>> >
>> > [org.clojure/clojurescript "0.0-2341"]
>> >
>> > This releases comes with considerably better analysis. Vars from other
>> > namespaces are finally also verified. Protocols previously saw very
>> > little analysis support. Protocol method implementations are now
>> > checked for validity against the declared protocol.
>> >
>> > Transducers are also now in sync with Clojure 1.7.0-alpha2
>> >
>> > Feedback welcome!
>> >
>> > ### Enhancements
>> > * transducers
>> >
>> > ### Fixes
>> > * CLJS-704: warn if protocol extended to type multiple times in
>> extend-type
>> > * CLJS-702: warn if protocol doesn't match declared
>> > * CLJS-859: use https for the bootstrap script
>> > * CLJS-855: combinatorial code generation under advanced
>> > * CLJS-858: resolve-existing var does not check vars outside current ns
>> > * CLJS-852: same group-by as Clojure
>> > * CLJS-847: Safari toString fix
>> > * CLJS-846: preserve namespace metadata
>>
>  --
> 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/d/optout.
>

-- 
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/d/optout.


Understanding how a collection reduce itself

2014-09-23 Thread Hussein B.
Hi,

I spent a considerable time trying to understand reducers. I got the 
concept of how the map/filter function will return a function and it is not 
going to iterate over a sequence and it is not going to create a new 
sequence.

The missing part though, who is creating the sequence?
They say a collection now knows how to reduce it self but I'm not getting 
that. I tried and I failed.

Would you please help with that?

Thanks for help and time.

-- 
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/d/optout.


Re: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-23 Thread Hugo Duncan

laurent.pe...@gmail.com writes:

> Le mardi 23 septembre 2014, Stuart Sierra  a
> écrit :
>
>> I'm not sure I understand what you mean.
>>
>> `remove-ns` does not remove the namespace from the set of "loaded"
>> namespaces kept by `require`.  tools.namespace
>>  has a hack
>> 
>> to work around this.
>>
>
> Can this be fixed for clojure 1.7 (integrate clojure.namespace hack into
> 'remove-ns)? Or is there a reason I can't see right now in favor of the
> current behavior?

Or a new function added, e.g. `unload-ns`, that combines remove-ns with
updating the ref.

Hugo


signature.asc
Description: PGP signature


Re: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-23 Thread Laurent PETIT
2014-09-23 12:53 GMT+02:00 Hugo Duncan :

>
> laurent.pe...@gmail.com writes:
>
> > Le mardi 23 septembre 2014, Stuart Sierra 
> a
> > écrit :
> >
> >> I'm not sure I understand what you mean.
> >>
> >> `remove-ns` does not remove the namespace from the set of "loaded"
> >> namespaces kept by `require`.  tools.namespace
> >>  has a hack
> >> <
> https://github.com/clojure/tools.namespace/blob/a166936bd757b71348c7c1608569fc0fcb1318bd/src/main/clojure/clojure/tools/namespace/reload.clj#L19
> >
> >> to work around this.
> >>
> >
> > Can this be fixed for clojure 1.7 (integrate clojure.namespace hack into
> > 'remove-ns)? Or is there a reason I can't see right now in favor of the
> > current behavior?
>
> Or a new function added, e.g. `unload-ns`, that combines remove-ns with
> updating the ref.
>

Yeah, sure.

Just a question so my understanding levels up: are there usecases where one
would use the current behavior of removing a namespace not also removing it
from *loaded-libs* (and thus preventing it from being required without
:reload) ?



>
> Hugo
>



-- 
Laurent Petit

-- 
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/d/optout.


Re: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-23 Thread Hugo Duncan

laurent.pe...@gmail.com writes:

> Just a question so my understanding levels up: are there usecases where one
> would use the current behavior of removing a namespace not also removing it
> from *loaded-libs* (and thus preventing it from being required without
> :reload) ?

You can create namespaces without touching `require`, so I think it is
reasonable to expect you can remove them too, without any side effects
that will affect what `require` does.

Hugo


signature.asc
Description: PGP signature


Re: Clojure beginner: angst about "doing things right"

2014-09-23 Thread Tim Visher
On Mon, Sep 22, 2014 at 2:45 PM, J David Eisenberg
 wrote:
> As part of a larger program, I'm testing a function that will turn a string
> of days on which a class occurs (such as "MWF") into a list of seven
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it
> wrong, in the moral purity sense of the word. Something inside of me says,
> "You could have just used (map...) to do this the *right* way," but I can't
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?

Just for fun, I thought of a way to do this with map. The trick is to
not map over the days of the class, but instead map over the days of
the week, checking for matches in the class schedule.

(def week ["SU" "M" "T" "W" "TH" "F" "S" "SU"])

(def class-schedule "MWTHFSU")

(defn class-days [class-schedule]
  (->> class-schedule
   (re-seq #"(TH|SU|S|M|T|W|F)")
   (map first)
   set))

user=> (mapv (partial contains? (class-days class-schedule)) week)
[true true false true true true false true]

Anyway, it's such a trivial problem that I don't think anyone would
fault you one way or another (unless you were out there using an atom
or something to track state) but this is one way to do it with map.

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail

-- 
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/d/optout.


Feeding a list of clauses to core.match/match

2014-09-23 Thread Jony Hudson
OK, this is probably simple, but I can't seem to figure it out. Maybe 
someone who understands macros better than me can help :-)

I'd like to be able to write something like the following:

(def some-clauses
  '[[false _] :f
[true _] :t])

(match-clauses [[false 3]] some-clauses)

but I can't figure out how to write `match-clauses`. If `core.match/match` 
were a function it would be easy, but it isn't. Can someone give me a push 
in the right direction?

Thanks,


Jony

-- 
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/d/optout.


Re: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-23 Thread Laurent PETIT
Le mardi 23 septembre 2014, Hugo Duncan  a écrit :

>
> laurent.pe...@gmail.com  writes:
>
> > Just a question so my understanding levels up: are there usecases where
> one
> > would use the current behavior of removing a namespace not also removing
> it
> > from *loaded-libs* (and thus preventing it from being required without
> > :reload) ?
>
> You can create namespaces without touching `require`, so I think it is
> reasonable to expect you can remove them too, without any side effects
> that will affect what `require` does.


*sigh* all this ns / lib dichotomy seems so unnecessarily complex

>
> Hugo
>


-- 
Laurent Petit

-- 
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/d/optout.


Re: Clojure beginner: angst about "doing things right"

2014-09-23 Thread John Gabriele
On Monday, September 22, 2014 2:45:23 PM UTC-4, J David Eisenberg wrote:

>
> The good news: the code works. The bad news: I'm convinced I'm doing it 
> wrong, in the moral purity sense of the word. Something inside of me says, 
> "You could have just used (map...) to do this the *right* way," but I can't 
> see how to do it with (map). {snip}
>


General comment: It's my hope that we don't cause anyone to fret that their 
code doesn't meet some arbitrary standard of moral purity. :)

Your code looks ok, and others here have posted some great tips on making 
it even better. (I really like how the Clojure community is almost always 
willing to offer alternative elegant solutions!)

Here's some tidbits from me:

  * use `(:require [clojure.string :as str])` in your file's `ns` macro so 
you can write "str/replace" instead of the longer "clojure.string/replace"
  * no need to pass an empty list to days-number-maker, since you can just 
start yourself off with one in there inside a `let`.

BTW, you might enjoy Batsov's [Clojure Style 
Guide](https://github.com/bbatsov/clojure-style-guide).

-- John

-- 
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/d/optout.


Re: Feeding a list of clauses to core.match/match

2014-09-23 Thread Mayank Jain
Not sure but are you looking for something like this?
https://github.com/killme2008/defun

On Tue, Sep 23, 2014 at 8:19 PM, Jony Hudson  wrote:

> OK, this is probably simple, but I can't seem to figure it out. Maybe
> someone who understands macros better than me can help :-)
>
> I'd like to be able to write something like the following:
>
> (def some-clauses
>   '[[false _] :f
> [true _] :t])
>
> (match-clauses [[false 3]] some-clauses)
>
> but I can't figure out how to write `match-clauses`. If `core.match/match`
> were a function it would be easy, but it isn't. Can someone give me a push
> in the right direction?
>
> Thanks,
>
>
> Jony
>
> --
> 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/d/optout.
>

-- 
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/d/optout.


Re: Feeding a list of clauses to core.match/match

2014-09-23 Thread Jony Hudson
Mulling on this some more, I think it might be impossible.

My reasoning is: I'm trying to do this so I can determine the list of 
clauses at run-time. But `core.match/match` does its magic at compile time, 
so it seems unlikely that I'm going to get what I want!

Back to the drawing board ...


Jony

On Tuesday, 23 September 2014 15:49:45 UTC+1, Jony Hudson wrote:
>
> OK, this is probably simple, but I can't seem to figure it out. Maybe 
> someone who understands macros better than me can help :-)
>
> I'd like to be able to write something like the following:
>
> (def some-clauses
>   '[[false _] :f
> [true _] :t])
>
> (match-clauses [[false 3]] some-clauses)
>
> but I can't figure out how to write `match-clauses`. If `core.match/match` 
> were a function it would be easy, but it isn't. Can someone give me a push 
> in the right direction?
>
> Thanks,
>
>
> Jony
>

-- 
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/d/optout.


Re: transducers and async operations

2014-09-23 Thread Wilker
Yeah, I'm going to let it go, hopefully I'll find some way of handling it
on future, for now keeping the extra versions is not that bad.

Thank you everyone.

---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Woboinc Consultant
+55 81 82556600

On Mon, Sep 22, 2014 at 6:01 PM, Leon Grapenthin 
wrote:

> I don't see a way for a reducing function to make its return value depend
> on the result of another callback.
>
>
> On Monday, September 22, 2014 9:45:15 PM UTC+2, Wilker wrote:
>>
>> I understand Leon, but all that only applies on Java world... The issue
>> here is because I depend on async stuff, in Java you always have options to
>> do it sync, you don't need any of those callbacks at all, this is a JS API
>> issue. So in my case I really need the async factor here, I can't avoid it.
>>
>> Given that, would be possible to make transducers async? I think the big
>> deal of transducers is exactly don't having to re-write map, filter, etc...
>> That's why I'm really trying to get then to work on this situation, unless
>> someone knows for sure that its not possible, than I can accept the
>> limitations and keep all my custom versions that can handle async
>> processing...
>>
>> Thanks.
>>
>> ---
>> Wilker Lúcio
>> http://about.me/wilkerlucio/bio
>> Woboinc Consultant
>> +55 81 82556600
>>
>> On Mon, Sep 22, 2014 at 4:22 PM, Leon Grapenthin 
>> wrote:
>>
>>> The steps of your transducer composition are depending on each other.
>>> They can only produce a result from an input if they process it
>>> synchronously. If you had >> described, you would reenforce synchronous input processing: Once you would
>>> consume an item, the code would have the exact same blocking
>>> characteristics as if the functions were returning values instead of
>>> channels. You would have gained nothing for the cost of creating
>>> overhead.
>>>
>>>
>>> On Monday, September 22, 2014 1:53:52 AM UTC+2, Wilker wrote:

 Because it's Node-JS environment, and that can be the same for any
 async Javascript, you never wanna call sync operations (like sync ajax)
 because they block everything...

 I was noticing that is a non-issue at all in Java world, since you can
 always read blocking into the predicate, for example: (filter (comp >>> my-chan-pred))

 But in Javascript that's not possible since it can't support read
 blocking.

 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600

 On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin 
 wrote:

> Why would you want the the predicates and readdir to return channels?
>
> On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote:
>>
>> Just an add,
>>
>> I was thinking if we could have something like a "deref" running
>> during the transducers, in order to enable value unwrapping (that way we
>> could handle channels/values in same fashion). I understand that is
>> complicated maybe because overhead, and also more tricky into JS world 
>> were
>> you can't deref a channel into a sync fashion.
>>
>> But the point remains, there is way to seamlessly handle async and
>> sync operations using the same transducers? Or something like it.
>>
>> Best regards.
>>
>> ---
>> Wilker Lúcio
>> http://about.me/wilkerlucio/bio
>> Woboinc Consultant
>> +55 81 82556600
>>
>> On Sun, Sep 21, 2014 at 7:01 PM, Wilker  wrote:
>>
>>> Hi guys,
>>>
>>> I'm playing with transducers here, and trying out stuff just for
>>> fun, there is something that I'm kind stuck on how to approach. I
>>> understand the great abstraction that transducers provide over don't
>>> carrying about the input source type, but I'm struggling to deal with 
>>> async
>>> operations into my pipeline.
>>>
>>> For example, I'm working with Node.JS async API's for file system
>>> operations, I want to stick with the async versions since I don't wanna
>>> block the event loop of Node.
>>>
>>> So, let's say I have a source with ["dir", "other"] and I wanna
>>> create an operation that will simple filter which paths exists, are
>>> directories, and then list the `ls` of each remaining entry.
>>>
>>> So, I first created "channel returning" functions for the Node
>>> operations, I'll not put the code here because I don't think it's really
>>> relevant here, just consider that I have them.
>>>
>>> So, my pipeline would start looking something like this:
>>>
>>> (comp (filter exists?)
>>>   (filter is-dir?)
>>>   (mapcat readdir))
>>>
>>> Of course, this doesn't works... Because `exists?`, `is-dir?` and
>>> `readdir`, all of them return channels, so the filter would always pass
>>> since a channel is always a valid value... The same applies to mapcat, 
>>> it
>>> would try to concat into a channel...

Re: {ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-23 Thread J David Eisenberg


On Saturday, September 13, 2014 11:47:28 PM UTC-7, dennis wrote:
>
>
> Hi , i am pleased to introduce defun : 
> a beautiful macro to define clojure functions with pattern match.
>
> [snip]
>

This is totally wonderful. Elegant, and useful. 

-- 
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/d/optout.


Re: How do I track down a painfully long pause in a small web app?

2014-09-23 Thread larry google groups
I am intrigued by this article, as the problem sounds the same as mine:

http://corner.squareup.com/2014/09/logging-can-be-tricky.html

"No significant amount of resources appeared to be in use — disk I/O, 
network I/O, CPU, and memory all looked fairly tame. Furthermore, the bulk 
of queries being served were all performing as expected. "

So I tried to follow their example regarding strace. But I have never 
worked with strace before. I used grep to find the PID and then I:

 sudo strace -c -f -p 19363

and I got:

Process 19363 attached with 45 threads

Then I ran our "health check" which is like a series of functional tests 
that ping our actual app (a live environment rather than a test 
environment). I got nothing out of strace except these 2 lines appeared:

Process 20973 attached
Process 20974 attached

What does this mean? I had the impression that the JVM ran in 1 process? 
Does strace show me userland threads (like htop does) or are these child 
processes? 





On Monday, September 15, 2014 12:15:14 AM UTC-4, larry google groups wrote:
>
>
> I have an embarrassing problem. I convinced my boss that I could use 
> Clojure to build a RESTful API. I was successful in so far as that went, 
> but now I face the issue that every once in a while, the program pauses, 
> for a painfully long time -- sometimes 30 seconds, which causes some 
> requests to the API to timeout. We are still in testing, so there is no 
> real load on the app, just the frontenders, writing Javascript and making 
> Ajax calls to the service. 
>
> The service seems like a basic Clojure web app. I use Jetty as the 
> webserver, and the libraries in use are: 
>
> Ring
>
> Compojure
>
> Liberator
>
> Monger 
>
> Timbre
>
> Lamina
>
> Dire
>
> When someone complains about the pauses, I will go test the service, and I 
> can hit with 40 requests in 10 seconds and it has great performance. The 
> pauses actually seem to come after periods of inactivity, which made me 
> think that this had something to do with garbage collection, except that 
> the pauses are so extreme -- like I said, sometimes as much as 30 seconds, 
> causing requests to timeout. When the app does finally start to respond it 
> again, it goes very fast, and responds to those pending request very fast. 
>
> But I have to find a way to fix these pauses. 
>
> Right now I packaged the app as an Uberjar and put it on the server, spun 
> it up on port 24000 and proxied it through Apache. I put a script in 
> /etc/init.d to start the app using  start-stop-daemon.
>
> Possible things that could be going wrong:
>
> Maybe Jetty needs more threads, or maybe less threads? How would I test 
> that?
>
> Maybe the link to MongoDB sometimes dies? (Mongo is on another server at 
> Amazon) How would I test that? 
>
> Maybe it is garbage collection? How would I test that? 
>
> Maybe I have some code that somehow blocks the whole app? Seems unlikely 
> but I'm trying to keep an open mind. 
>
> Maybe the thread pool managed by Lamina sometimes gets overwhelmed? How 
> would I test that? 
>
> Maybe when Timbre writes to the log file it causes things to pause? (But I 
> believe Timbre does this in its own thread?) How do I test that? 
>
> This is a small app: only about 1,100 lines of code.
>
> I don't have much experience debugging problems on the JVM, so I welcome 
> any suggestions. 
>
>
>
>
>
>
>
>

-- 
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/d/optout.


Re: How do I track down a painfully long pause in a small web app?

2014-09-23 Thread larry google groups
I'm guessing that strace is showing me userland threads? When I quit strace 
I see:

^CProcess 19363 detached
Process 19364 detached
Process 19365 detached
Process 19366 detached
Process 19367 detached
Process 19368 detached
Process 19369 detached
Process 19370 detached
Process 19371 detached
Process 19372 detached
Process 19377 detached
Process 19378 detached
Process 19379 detached
Process 19380 detached
Process 19381 detached
Process 19382 detached
Process 19383 detached
Process 19384 detached
Process 19385 detached
Process 19386 detached
Process 19387 detached
Process 19388 detached
Process 19389 detached
Process 19390 detached
Process 19391 detached
Process 19392 detached
Process 19393 detached
Process 19394 detached
Process 19395 detached
Process 19396 detached
Process 19397 detached
Process 19398 detached
Process 19399 detached
Process 19400 detached
Process 19401 detached
Process 19402 detached
Process 19403 detached
Process 19404 detached
Process 19405 detached
Process 19406 detached
Process 19407 detached
Process 19408 detached
Process 19409 detached
Process 19410 detached
Process 19606 detached
% time seconds  usecs/call callserrors syscall
-- --- --- - - 
 90.06   40.9730721363 30059 10449 futex
  4.231.926411 819  2353   epoll_wait
  3.021.373282  11444012 6 restart_syscall
  1.240.563107   93851 6   accept
  0.990.449988  12 36909   gettimeofday
  0.350.156992   5 29410   clock_gettime
  0.050.021064  67   316   recvfrom
  0.020.010338  30   347   write
  0.010.005117  24   209   sendto
  0.010.004369  24   180   poll
  0.010.002683  24   11222 read
  0.010.002563  24   108 6 epoll_ctl
  0.000.001618  14   112   open
  0.000.001189   5   230   fcntl
  0.000.001132   8   142   mprotect
  0.000.000969   8   118   close
  0.000.000806  3821   writev
  0.000.000685   6   109   ioctl
  0.000.000655   6   110   fstat
  0.000.000229  1317   mmap
  0.000.000216  36 6   shutdown
  0.000.000197  33 6   dup2
  0.000.92  46 2   madvise
  0.000.61   512   setsockopt
  0.000.57  14 4   munmap
  0.000.56   512   getsockname
  0.000.35   4 8   rt_sigprocmask
  0.000.18   5 4   sched_getaffinity
  0.000.10   5 2   clone
  0.000.09   9 1   rt_sigreturn
  0.000.09   5 2   uname
  0.000.09   5 2   set_robust_list
  0.000.08   4 2   gettid
-- --- --- - - 
100.00   45.497046100943 10483 total






On Tuesday, September 23, 2014 9:44:52 PM UTC-4, larry google groups wrote:
>
> I am intrigued by this article, as the problem sounds the same as mine:
>
> http://corner.squareup.com/2014/09/logging-can-be-tricky.html
>
> "No significant amount of resources appeared to be in use — disk I/O, 
> network I/O, CPU, and memory all looked fairly tame. Furthermore, the bulk 
> of queries being served were all performing as expected. "
>
> So I tried to follow their example regarding strace. But I have never 
> worked with strace before. I used grep to find the PID and then I:
>
>  sudo strace -c -f -p 19363
>
> and I got:
>
> Process 19363 attached with 45 threads
>
> Then I ran our "health check" which is like a series of functional tests 
> that ping our actual app (a live environment rather than a test 
> environment). I got nothing out of strace except these 2 lines appeared:
>
> Process 20973 attached
> Process 20974 attached
>
> What does this mean? I had the impression that the JVM ran in 1 process? 
> Does strace show me userland threads (like htop does) or are these child 
> processes? 
>
>
>
>
>
> On Monday, September 15, 2014 12:15:14 AM UTC-4, larry google groups wrote:
>>
>>
>> I have an embarrassing problem. I convinced my boss that I could use 
>> Clojure to build a RESTful API. I was successful in so far as that went, 
>> but now I face the issue that every once in a while, the program pauses, 
>> for a painfully long time -- sometimes 30 seconds, which causes some 
>> requests to the API to timeout. We are still in testing, so there is no 
>> real load on the app, just the frontenders, writing Javascript an