<div dir="ltr"><div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 19, 2013 at 5:17 PM, Manik Surtani <span dir="ltr">&lt;<a href="mailto:msurtani@redhat.com" target="_blank">msurtani@redhat.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 19 Mar 2013, at 15:07, Sanne Grinovero &lt;<a href="mailto:sanne@redhat.com">sanne@redhat.com</a>&gt; wrote:<br>
<br>
&gt;<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt;&gt;<br>
&gt;&gt; On 19 Mar 2013, at 12:21, Mircea Markus &lt;<a href="mailto:mmarkus@redhat.com">mmarkus@redhat.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On 19 Mar 2013, at 11:05, Sanne Grinovero wrote:<br>
&gt;&gt;&gt;&gt; Does Marshalling really need to be performed in a separate thread<br>
&gt;&gt;&gt;&gt; pool?<br>
&gt;&gt;&gt;&gt; I think we have too many pools, too much context switching, and<br>
&gt;&gt;&gt;&gt; situations like this one which should be avoided.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; We could document it  but all these details are making it very<br>
&gt;&gt;&gt;&gt; hard to feel comfortable with, and for this specific use case I<br>
&gt;&gt;&gt;&gt; wonder if there<br>
&gt;&gt;&gt;&gt; is a strong benefit: plain serial operations seem so much cleaner<br>
&gt;&gt;&gt;&gt; to me.<br>
&gt;&gt;&gt; +1 for dropping it in 6.0. It isn&#39;t enabled by default and AFAIK it<br>
&gt;&gt;&gt; created more confusion through the users than benefits.<br>
&gt;&gt;<br>
&gt;&gt; Why?  I don&#39;t agree.  If network transfer is the most expensive part<br>
&gt;&gt; of performing a write, then marshalling is the second-most<br>
&gt;&gt; expensive.  If you don&#39;t take the marshalling offline as well,<br>
&gt;&gt; you&#39;re only realising a part of the performance gains of using<br>
&gt;&gt; async.<br>
&gt;<br>
&gt; Of course. I didn&#39;t mean to put it on the thread of the invoker, I would expect<br>
&gt; this to happen &quot;behind the scenes&quot; when using async, but in the same thread which<br>
&gt; is managing the lower IO so to reduce both context switching and these weird<br>
&gt; race conditions.. so removing the option only.<br>
<br>
Well, when using the same lower IO pool, while common sense, isn&#39;t as easy since it is a JGroups pool.  If we pass the marshaller itself into JGroups, the marshalling still happens online, and just the IO happening in a separate thread.  Also, JGroups allows you to register one marshaller and unmarshaller per channel - which doesn&#39;t work when you have a transport shared by multiple cache instances potentially on different class loaders.<br>


<br>
So yes, this can be done much better, but that means a fair few changes in JGroups such that:<br>
<br>
* Marshalling happens in the async thread (the same one that puts the message on the wire) rather than in the caller&#39;s thread<br>
* sendMessage() should accept a marshaller and unmarshaller per invocation<br>
<br>
Then we can drop this additional thread pool.<br>
<br></blockquote><div><br></div><div></div><div>The upper-most protocol in the default stack is FRAG2, and it already needs the serialized payload - it can&#39;t split an Object in 2 messages. Most other protocols need at least the message size. So there&#39;s no way our payload is going to get serialized only in the TP thread that actually puts the bytes on the wire.<br>

<br>In fact, I would go the other way around. Because we have multiple marshallers, I
 think it would be cleaner if we used MessageDispatcher directly and did
 the request/response serialization in Infinispan. <br><br></div><div>I wouldn&#39;t recommend async marshalling anyway. The user must be very 
careful not to modify the value object at any time after calling 
cache.put(key, value), so to me using async marshalling is just asking 
for trouble.<br><br></div><div>There are a couple places where I think we could save an async transport thread, but I don&#39;t think either would make a perceptible change in performance:<br></div><div>* Waiting for a response from the recipients is much slower than sending the message. If RpcManagerImpl.invokeRemotelyInFuture just sent the message and returned the JGroups Request object, I don&#39;t think we&#39;d need the thread pool there.<br>

</div><div>* We could also detect if the user invoked cache.putAsync and avoid using an extra async transport thread when the cache is async.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; On top of that the number of pools is growing (5.3 adds another<br>
&gt;&gt;&gt; pool in the scope of ISPN-2808).<br>
&gt;&gt;<br>
&gt;&gt; You can configure to use a single thread pool for all these tasks, if<br>
&gt;&gt; hanging on to multiple thread pools is too complex.<br>
&gt;<br>
&gt; I don&#39;t believe you can always do that, if you don&#39;t keep tasks isolated<br>
&gt; in different pools deadlocks could happen. So unless you can come up with<br>
&gt; a nice diagram and explain which ones are safe to share, it is very<br>
&gt; complex to handle.<br>
&gt;<br></blockquote><div><br></div><div>If queueing is disabled and the caller runs tasks when the thread pool is full, dependencies are not a problem. If queueing is enabled... yes, dependencies are a big problem. <br>

<br>But I&#39;m pretty sure you can have dependency cycles with 2 thread pools as well, if both have queueing enabled.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


&gt; Would be nice to have these discussions on the public mailing list.<br>
<br>
+1.  Adding infinispan-dev in cc.<br>
<br>
&gt;<br>
&gt; Sanne<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; - M<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Manik Surtani<br>
&gt;&gt; <a href="mailto:manik@jboss.org">manik@jboss.org</a><br>
&gt;&gt; <a href="http://twitter.com/maniksurtani" target="_blank">twitter.com/maniksurtani</a><br>
&gt;&gt;<br>
&gt;&gt; Platform Architect, JBoss Data Grid<br>
&gt;&gt; <a href="http://red.ht/data-grid" target="_blank">http://red.ht/data-grid</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
--<br>
Manik Surtani<br>
<a href="mailto:manik@jboss.org">manik@jboss.org</a><br>
<a href="http://twitter.com/maniksurtani" target="_blank">twitter.com/maniksurtani</a><br>
<br>
Platform Architect, JBoss Data Grid<br>
<a href="http://red.ht/data-grid" target="_blank">http://red.ht/data-grid</a><br>
<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</blockquote></div><br></div></div></div>