<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 6:14 PM, William Burns <span dir="ltr">&lt;<a href="mailto:mudokonman@gmail.com" target="_blank">mudokonman@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Wed, Oct 8, 2014 at 10:57 AM, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Oct 8, 2014 at 5:42 PM, William Burns &lt;<a href="mailto:mudokonman@gmail.com">mudokonman@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; So it seems we would want to change this for 7.0 if possible since it<br>
&gt;&gt; would be a bigger change for something like 7.1 and 8.0 would be even<br>
&gt;&gt; further out.  I should be able to put this together for CR2.<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m not 100% convinced that we need it for 7.x. For 8.0 I would recommend<br>
&gt; removing the size() method altogether, and providing some looser<br>
&gt; &quot;statistics&quot; instead.<br>
<br>
</span>Yeah I guess I don&#39;t know enough about the demand for these methods or<br>
what people wanted to use them for to know what kind of priority they<br>
should be given.<br>
<br>
It sounds like you are talking about decoupling from the<br>
Map/ConcurrentMap interface completely then, right?  So we would also<br>
eliminate the other bulk methods (keySet, values, entrySet)?<br></blockquote><div><br></div><div>Yes, I would base the Cache interface on JSR-107&#39;s Cache, which doesn&#39;t have size() or the other methods.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; It seems that we want to implement keySet, values and entrySet methods<br>
&gt;&gt; using the entry iterator approach.<br>
&gt;&gt;<br>
&gt;&gt; It is however unclear for the size method if we want to use MR entry<br>
&gt;&gt; counting and not worry about the rehash and passivation issues since<br>
&gt;&gt; it is just an estimation anyways.  Or if we want to also use the entry<br>
&gt;&gt; iterator which should be closer approximation but will require more<br>
&gt;&gt; network overhead and memory usage.<br>
&gt;<br>
&gt;<br>
&gt; +1 to use the entry iterator from me, ignoring state transfer we can get<br>
&gt; some pretty wild fluctuations in the size of the cache.<br>
<br>
</span>That is personally my feeling as well, but I tend to err more on the<br>
side of correctness to begin with.<br>
<span class=""><br>
&gt; We could use a distributed task for Cache.isEmpty() instead of size() == 0,<br>
&gt; though.<br>
<br>
</span>Yes that should be a good optimization either way.<br>
<span class=""><br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Also we didn&#39;t really talk about the fact that these methods would<br>
&gt;&gt; ignore ongoing transactions and if that is a concern or not.<br>
&gt;&gt;<br>
&gt;<br>
&gt; It might be a concern for the Hibernate 2LC impl, it was their TCK that<br>
&gt; prompted the last round of discussions about clear().<br>
<br>
</span>Although I wonder how much these methods are even used since they only<br>
work for Local, Replication or Invalidation caches in their current<br>
state (and didn&#39;t even use loaders until 6.0).<br></blockquote><div><br></div><div>There is some more information about the test in the mailing list discussion [1]</div><div>There&#39;s also a JIRA for clear() [2]</div><div><br></div><div>I think 2LC almost never uses distribution, so size() being local-only didn&#39;t matter, but making it non-tx could cause problems - at least for that particular test.</div><div><br></div><div>[1] <a href="http://lists.jboss.org/pipermail/infinispan-dev/2013-October/013914.html">http://lists.jboss.org/pipermail/infinispan-dev/2013-October/013914.html</a></div><div>[2] <a href="https://issues.jboss.org/browse/ISPN-3656">https://issues.jboss.org/browse/ISPN-3656</a></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
&gt;<br>
&gt; We haven&#39;t talked about what size(), keySet() and values() should return for<br>
&gt; an invalidation cache either... I forget, does the distributed entry<br>
&gt; iterator work with invalidation caches?<br>
<br>
</span>It works the same as a local cache so only the local node contents are<br>
returned.  Replicated does the same thing, distributed is the only<br>
special case.  This was the only thing that made sense to me, but if<br>
you have any ideas that would  be great to hear for possibly enhancing<br>
Invalidation iteration.<br></blockquote><div><br></div><div>Sounds good to me. </div><div><br></div><div>cache.get(k) will search on all the nodes via ClusterLoader, so there is a certain appeal in making the entry iterator do the same. But invalidation caches are used with an external (non-CacheLoader) source of data anyway, so we can never return &quot;all the entries&quot;.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;  - Will<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Oct 8, 2014 at 10:13 AM, Mircea Markus &lt;<a href="mailto:mmarkus@redhat.com">mmarkus@redhat.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Oct 8, 2014, at 15:11, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Wed, Oct 8, 2014 at 5:03 PM, Mircea Markus &lt;<a href="mailto:mmarkus@redhat.com">mmarkus@redhat.com</a>&gt;<br>
&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; On Oct 3, 2014, at 9:30, Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; recently we had a discussion about what size() returns, but I&#39;ve<br>
&gt;&gt; &gt;&gt; &gt; realized there are more things that users would like to know. My<br>
&gt;&gt; &gt;&gt; &gt; question is whether you think that they would really appreciate it,<br>
&gt;&gt; &gt;&gt; &gt; or<br>
&gt;&gt; &gt;&gt; &gt; whether it&#39;s just my QA point of view where I sometimes compute the<br>
&gt;&gt; &gt;&gt; &gt; &#39;checksums&#39; of cache to see if I didn&#39;t lost anything.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; There are those sizes:<br>
&gt;&gt; &gt;&gt; &gt; A) number of owned entries<br>
&gt;&gt; &gt;&gt; &gt; B) number of entries stored locally in memory<br>
&gt;&gt; &gt;&gt; &gt; C) number of entries stored in each local cache store<br>
&gt;&gt; &gt;&gt; &gt; D) number of entries stored in each shared cache store<br>
&gt;&gt; &gt;&gt; &gt; E) total number of entries in cache<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; So far, we can get<br>
&gt;&gt; &gt;&gt; &gt; B via withFlags(SKIP_CACHE_LOAD).size()<br>
&gt;&gt; &gt;&gt; &gt; (passivation ? B : 0) + firstNonZero(C, D) via size()<br>
&gt;&gt; &gt;&gt; &gt; E via distributed iterators / MR<br>
&gt;&gt; &gt;&gt; &gt; A via data container iteration + distribution manager query, but only<br>
&gt;&gt; &gt;&gt; &gt; without cache store<br>
&gt;&gt; &gt;&gt; &gt; C or D through<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; getComponentRegistry().getLocalComponent(PersistenceManager.class).getStores()<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; I think that it would go along with users&#39; expectations if size()<br>
&gt;&gt; &gt;&gt; &gt; returned E and for the rest we should have special methods on<br>
&gt;&gt; &gt;&gt; &gt; AdvancedCache. That would of course change the meaning of size(), but<br>
&gt;&gt; &gt;&gt; &gt; I&#39;d say that finally to something that has firm meaning.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; WDYT?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; There was a lot of arguments in past whether size() and other methods<br>
&gt;&gt; &gt;&gt; that operate over all the elements (keySet, values) are useful because:<br>
&gt;&gt; &gt;&gt; - they are approximate (data changes during iteration)<br>
&gt;&gt; &gt;&gt; - they are very resource consuming and might be miss-used (this is the<br>
&gt;&gt; &gt;&gt; reason we chosen to use size() with its current local semantic)<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; These methods (size, keys, values) are useful for people and I think we<br>
&gt;&gt; &gt;&gt; were not wise to implement them only on top of the local data: this is like<br>
&gt;&gt; &gt;&gt; preferring efficiency over correctness. This also created a lot of confusion<br>
&gt;&gt; &gt;&gt; with our users, question like size() doesn&#39;t return the correct value being<br>
&gt;&gt; &gt;&gt; asked regularly. I totally agree that size() returns E (i.e. everything that<br>
&gt;&gt; &gt;&gt; is stored within the grid, including persistence) and it&#39;s performance<br>
&gt;&gt; &gt;&gt; implications to be documented accordingly. For keySet and values - we should<br>
&gt;&gt; &gt;&gt; stop implementing them (throw exception) and point users to Will&#39;s<br>
&gt;&gt; &gt;&gt; distributed iterator which is a nicer way to achieve the desired behavior.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; We can also implement keySet() and values() on top of the distributed<br>
&gt;&gt; &gt;&gt; entry iterator and document that using the iterator directly is better.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Yes, that&#39;s what I meant as well.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Cheers,<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; Mircea Markus<br>
&gt;&gt; &gt; Infinispan lead (<a href="http://www.infinispan.org" target="_blank">www.infinispan.org</a>)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; infinispan-dev mailing list<br>
&gt;&gt; &gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><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>
</div></div></blockquote></div><br></div></div>