users@jersey.java.net

Re: [Jersey] Client: Performance: InputStream fastest possibility?

From: Johannes Schneider <mailings_at_cedarsoft.com>
Date: Wed, 10 Nov 2010 10:30:16 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Finally I found time to test the apache client.
The results are not as I expected:

The performance is slower that with the default client (about 5% in my
test cases). But the major problem is, that there seems to happen dead
locks sometimes.
Don't know if that is a problem with my client code (probably). I am
switching back to the default client.

Here is a thread dump - just if somebody is interested:


Full thread dump Java HotSpot(TM) 64-Bit Server VM (17.1-b03 mixed mode):

"MultiThreadedHttpConnectionManager cleanup" daemon prio=10
tid=0x0000000040c43000 nid=0x5c2f in Object.wait() [0x00007f3f2f69e000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00007f3f3b284198> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
        - locked <0x00007f3f3b284198> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
        at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ReferenceQueueThread.run(MultiThreadedHttpConnectionManager.java:1122)

"Monitor Ctrl-Break" daemon prio=10 tid=0x00007f3f303b0000 nid=0x5c2d
runnable [0x00007f3f2f97c000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
        - locked <0x00007f3f8fdde138> (a java.io.InputStreamReader)
        at java.io.InputStreamReader.read(InputStreamReader.java:167)
        at java.io.BufferedReader.fill(BufferedReader.java:136)
        at java.io.BufferedReader.readLine(BufferedReader.java:299)
        - locked <0x00007f3f8fdde138> (a java.io.InputStreamReader)
        at java.io.BufferedReader.readLine(BufferedReader.java:362)
        at com.intellij.rt.execution.application.AppMain$1.run(AppMain.java:77)
        at java.lang.Thread.run(Thread.java:662)

"Low Memory Detector" daemon prio=10 tid=0x00007f3f30003800 nid=0x5c2b
runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x00007f3f30001000 nid=0x5c2a
waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x0000000040a85000 nid=0x5c29
waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0000000040a82800 nid=0x5c28
waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x0000000040a64000 nid=0x5c27 in
Object.wait() [0x00007f3f348d9000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00007f3f3b284540> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
        - locked <0x00007f3f3b284540> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x0000000040a5c800 nid=0x5c26 in
Object.wait() [0x00007f3f349da000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00007f3f3b284628> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:485)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x00007f3f3b284628> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x00000000409fb000 nid=0x5c20 in Object.wait()
[0x00007f3fbc06d000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00007f3f3b283d20> (a
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ConnectionPool)
        at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:518)
        - locked <0x00007f3f3b283d20> (a
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ConnectionPool)
        at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:416)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
com.sun.jersey.client.apache.ApacheHttpClientHandler.handle(ApacheHttpClientHandler.java:251)
        at com.sun.jersey.api.client.Client.handle(Client.java:569)
        at com.sun.jersey.api.client.WebResource.handle(WebResource.java:556)
        at com.sun.jersey.api.client.WebResource.get(WebResource.java:179)
        at
com.cedarsoft.collustra.couch.CouchDatabase.query(CouchDatabase.java:127)
        at com.cedarsoft.collustra.couch.CouchDatabase.query(CouchDatabase.java:89)
        at
com.cedarsoft.collustra.couch.registry.CouchDBRegistrySerializingStrategy.deserialize(CouchDBRegistrySerializingStrategy.java:87)
        at
com.cedarsoft.serialization.registry.RegistrySerializer.deserialize(RegistrySerializer.java:114)
        at
com.cedarsoft.serialization.registry.RegistrySerializer.createConnectedRegistry(RegistrySerializer.java:153)
        at
com.cedarsoft.collustra.couch.CouchDatabaseRunner.main(CouchDatabaseRunner.java:368)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)

"VM Thread" prio=10 tid=0x0000000040a58000 nid=0x5c25 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x0000000040a0e000
nid=0x5c21 runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x0000000040a0f800
nid=0x5c22 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x0000000040a11800
nid=0x5c23 runnable

"GC task thread#3 (ParallelGC)" prio=10 tid=0x0000000040a13800
nid=0x5c24 runnable

"VM Periodic Task Thread" prio=10 tid=0x00007f3f30016800 nid=0x5c2c
waiting on condition

JNI global references: 1232

Heap
 PSYoungGen total 30336K, used 28742K [0x00007f3f8e570000,
0x00007f3f91d30000, 0x00007f3fb80c0000)
  eden space 26880K, 94% used
[0x00007f3f8e570000,0x00007f3f8fe229a0,0x00007f3f8ffb0000)
  from space 3456K, 99% used
[0x00007f3f90960000,0x00007f3f90cbf230,0x00007f3f90cc0000)
  to space 11456K, 0% used
[0x00007f3f91200000,0x00007f3f91200000,0x00007f3f91d30000)
 PSOldGen total 85376K, used 8715K [0x00007f3f3aec0000,
0x00007f3f40220000, 0x00007f3f8e570000)
  object space 85376K, 10% used
[0x00007f3f3aec0000,0x00007f3f3b742e88,0x00007f3f40220000)
 PSPermGen total 21248K, used 10627K [0x00007f3f35ac0000,
0x00007f3f36f80000, 0x00007f3f3aec0000)
  object space 21248K, 50% used
[0x00007f3f35ac0000,0x00007f3f36520dc8,0x00007f3f36f80000)



On 09/23/2010 11:04 PM, Johannes Schneider wrote:
> On 09/23/2010 07:15 PM, Paul Sandoz wrote:
>
>> By default Jersey defers to HttpURLConnection, which is what you are
>> using, but you can also defer to the Apache HTTP client if one needs
>> additional features.
>
>> https://jersey.dev.java.net/nonav/apidocs/1.4/contribs/jersey-apache-client/com/sun/jersey/client/apache/package-summary.html
>
>> https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#core_client
>
>
> Thanks for those hints. I will try that out.
>
>
> Johannes
>
>
>> Difficult to know the reason why the InputStream might be blocking
>> without knowing more about your environment,
>
>> Paul.
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>

- ---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net


- --
Johannes Schneider - blog.cedarsoft.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEcBAEBAgAGBQJM2mYoAAoJEAytD9R7Qv6dWccH/06sY9+hGs11KMFDo+MlBC+d
FTh+STuS3UgsX6tSBxHzfh78TXcT5zo8tZQfVjpzenb3JcrZMY5fSFVTovBcjvjF
IcwULmFscMNIkAazKnwfqgJGkxpsoXvfZGaeNT/8i3+dvinACA7/wLvADkiOxkwi
aJzLqDi3bcfLbhOClZPiUSycF9XyL4qL1cD6vS41nXw3xdSxIXvmJmhgrad2VNoh
iIEBMTj09yl7iiLilApCMe3JNwLX8Ax7r/zFmB4FJszUuJ7uAl94gopBLj97P8fA
IGnSokYruiCHk+p8IN7UgaYirjLkAyKCJMcMkQ6qQFi9MiSvJpKyjfqCoA9wf+A=
=UjQQ
-----END PGP SIGNATURE-----