<div dir="ltr">I think we may be confusing two different features. These changes are what I was hoping could be used as a basis for the transformers work (doesn&#39;t mean they will be). These changes were done before there was any discussions about transformers though, so they may not have the use cases covered. I think this might be why there was some confusion.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 1, 2017 at 8:11 AM Sanne Grinovero &lt;<a href="mailto:sanne@infinispan.org">sanne@infinispan.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks all for the great explanations.<br>
<br>
+1 to try to avoid this. Could the transformation be performed lazily?<br></blockquote><div><br></div><div>I can&#39;t think of a reason we can&#39;t try to avoid the collection allocations with what I proposed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We had a design meeting about transformers and that was a goal we had<br>
agreed on.</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
For example in the Search case, I&#39;m doing a getAll( keys ) just to<br>
return the objects in a sorted list back to the user - in whatever<br>
form they are.<br>
In this case the engine doesn&#39;t need the objects to be in any specific<br>
form, so the transformation / wrapping phase needs to be moved to the<br>
client endpoint to become an optional, transparent step.<br></blockquote><div><br></div><div>These changes have nothing to do with the client itself. In fact these were mostly added for byte[] requirements. I just added in Compatibility support which required the same type of code.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Some more comments inline:<br>
<br>
On 1 June 2017 at 11:12, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com" target="_blank">dan.berindei@gmail.com</a>&gt; wrote:<br>
&gt; On Wed, May 31, 2017 at 10:05 PM, William Burns &lt;<a href="mailto:mudokonman@gmail.com" target="_blank">mudokonman@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Let me explain why it is there first :) This class was added for two main<br>
&gt;&gt; reasons: as a replacement for compatibility and for supporting equality of<br>
&gt;&gt; byte[] object. What this class does is at the user side is box the given<br>
&gt;&gt; arguments (eg. byte[] -&gt; WrappedByteArray) then the cache only ever deals<br>
&gt;&gt; with the boxed types and then does the unboxing for any values that are<br>
&gt;&gt; returned.<br>
&gt;&gt;<br>
&gt;&gt; There are some exceptions with how the boxing/unboxing works for both cases<br>
&gt;&gt; such as Streams and Indexing which have to rebox the data to work properly.<br>
&gt;&gt; But the cost is pretty minimal.<br>
&gt;&gt;<br>
&gt;&gt; While compatibility is always on or off unfortunately anyone can pass in a<br>
&gt;&gt; byte[] at any point for a key or value. So we need to have these wrappers<br>
&gt;&gt; there to make sure they work properly.<br>
&gt;&gt;<br>
&gt;&gt; We could add a option to the cache, which people didn&#39;t show interest<br>
&gt;&gt; before, to have a cache that doesn&#39;t support byte[] or compatibility. In<br>
&gt;&gt; this case there would be no need for the wrapper.<br>
<br>
Let&#39;s try to avoid a configuration option; if the Transformers design<br>
I mentioned above doesn&#39;t fly we could have Infinispan Query use a<br>
dedicated internal API which skips such operations.<br>
<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Compatibility<br>
&gt;&gt;<br>
&gt;&gt; By using the wrapper around the cache, compatibility becomes quite trivial<br>
&gt;&gt; since we just need a converter in the wrapper and it does everything else<br>
&gt;&gt; for us. My guess is the new encoding changes will utilise these wrapper<br>
&gt;&gt; classes as well as they are quite easy to plug in and have things just work.<br>
<br>
Remember there&#39;s more than byte[] vs Pojo, as we also have other<br>
formats which need supporting, and plans to support JSON as well<br>
(which is not a String nor a POJO).<br>
<br>
The query engine will likely need to convert / interpret the &quot;storage<br>
format&quot; into its own format, or like Adrian pointed out being a great<br>
capability of Protobuf is to read only a selection of fields.<br>
<br>
So I wouldn&#39;t automatically apply these operations, as they must be<br>
client dependent. Tristan has the design documents from the Infinispan<br>
Query meeting we held in London, I briefly pointed Will to them during<br>
our Konstanz meeting. May I hope that&#39;s going to be the next step?</blockquote><div><br></div><div>This is what Gustavo and others are working on.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sounds like it would also avoid this performance issue.<br></blockquote><div><br></div><div>I can&#39;t say, but the byte[] is another issue, since it is needed outside of client/server.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
&gt;&gt; Equality<br>
&gt;&gt;<br>
&gt;&gt; With the rewrite for eviction we lost the ability to use custom Equality in<br>
&gt;&gt; the data container. The only option for that is to wrap a byte[] to provide<br>
&gt;&gt; our own equality. Therefore the wrapper does this conversion for us by<br>
&gt;&gt; converting between automatically.<br>
&gt;&gt;<br>
&gt;&gt; On Wed, May 31, 2017 at 2:34 PM Sanne Grinovero &lt;<a href="mailto:sanne@infinispan.org" target="_blank">sanne@infinispan.org</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;ve been running some benchmarks and for the fist time playing with<br>
&gt;&gt;&gt; Infinispan 9+, so please bear with me as I might shoot some dumb<br>
&gt;&gt;&gt; questions to the list in the following days.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The need for TypeConverterDelegatingAdvancedCache to wrap most<br>
&gt;&gt;&gt; operations - especially &quot;convertKeys&quot; - is highlighet as one of the<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; It should be wrapping every operation pretty much.<br>
&gt;&gt;<br>
&gt;&gt; Unfortunately the methods this hurts the most are putAll, getAll etc as they<br>
&gt;&gt; have to not only box every entry but copy them into a new collection as you<br>
&gt;&gt; saw in &quot;convertKeys&quot;. And for getAll it also has to unbox the return as<br>
&gt;&gt; well.<br>
&gt;&gt;<br>
&gt;&gt; We could reduce allocations in the collection methods by not creating the<br>
&gt;&gt; new collection until we run into one key or value that required<br>
&gt;&gt; boxing/unboxing. This would still require fully iterating over the<br>
&gt;&gt; collection at best case. This should perform well in majority of cases as I<br>
&gt;&gt; would expect all or almost all entries either require or don&#39;t require the<br>
&gt;&gt; boxing. The cases that would be harmed most would be ones that have a sparse<br>
&gt;&gt; number of entries that require boxing.<br>
&gt;&gt;<br>
&gt;<br>
&gt; +1 for checking the keys/values first and only creating a new<br>
&gt; collection if necessary, although it doesn&#39;t seem possible with the<br>
&gt; current TypeConverter interface.<br>
<br>
+1<br>
<br>
&gt; I&#39;m also fine with adding a configuration option to prohibit byte[]<br>
&gt; keys/values, but I&#39;d still want to check the collection and throw an<br>
&gt; exception (at least for writes).<br>
&gt;<br>
&gt; Thinking further, do we really need to wrap byte[] values?<br>
&gt; DataContainer only has a compute() method, so we may be able to<br>
&gt; replace the value wrappers with a TypeConverter.valuesEqual(a, b)<br>
&gt; method.<br>
&gt;<br>
&gt; Also, Sanne, could you change InternalCacheFactory.createAndWire() to<br>
&gt; return the un-wrapped cache, and then see exactly much the wrapping<br>
&gt; affects performance? With so many moving parts, I wouldn&#39;t be<br>
&gt; surprised if the difference in numbers was &lt; 1%.<br>
<br>
Indeed, I don&#39;t expect a significant change in throughput: it&#39;s an<br>
allocation issue and as such it&#39;s very situational if it&#39;s going to<br>
affect someone or not. Not worth measuring as my current bottleneck is<br>
caused by other open issues.<br>
<br>
But my main concern now is that apparently this approach does not<br>
address some of our needs as previously agreed, which we need to<br>
improve usability such as transparent transcoding. I guess that&#39;s<br>
coming next? In that case we can drop it for now, it&#39;s no big deal and<br>
I was just hoping to have identified a low hanging fruit.<br></blockquote><div><br></div><div>Yeah I am looking forward to the new changes as well :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
Sanne<br>
<br>
&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; high allocators in my Search-centric use case.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m wondering:<br>
&gt;&gt;&gt;  A - Could this implementation be improved?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Most anything can be improved :) The best way would be to add another knob.<br>
&gt;&gt;<br>
&gt;&gt;&gt;  B - Could I bypass / disable it? Not sure why it&#39;s there.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; There is no way to bypass currently. Explained above.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt; Sanne<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" 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" target="_blank">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</blockquote></div></div>