<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 21, 2016 at 6:56 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">Hey Galder,<br>
these &quot;scopes&quot; you mention sound cool, but I&#39;m afraid you&#39;d end up<br>
designing a user friendly API more than allowing the level of<br>
performance optimisations we need.<br>
<br>
If we pass a &quot;context&quot; map, or eventually make it a map of maps when<br>
you&#39;ll figure you have nested structures such as [object type, object<br>
id], then:<br>
 - each deserialization event will need to perform multiple<br>
[concurrent]Map lookups<br></blockquote><div> </div><div>Unfortunately my implementation is quite similar although it is using a HashMap and IdentityMap.  The main benefit of the externalizer I had was that it only affected instances that extend it.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 - I wouldn&#39;t be able to plug in an ad-hoc data structure: e.g. Will&#39;s<br>
&quot;instance&quot; strategy seems efficient :)<br>
 - we&#39;ll need to implement size-capping strategies, i.e. these would<br>
need to support eviction strategies, not least configuration options<br>
for such eviction.<br>
 - similar cost traversing multiple [concurrent]Map to write to the<br>
&quot;context cache&quot;<br>
<br>
I would suggest instead to give more flexibility to custom<br>
Externalizer implementors by making them stateful: if you could allow<br>
them to have something akin to the ComponentRegistry injected within<br>
the constructor, then a power user could pre-register custom services,<br>
look them up only once during construction, and then benefit from the<br>
performance of final field reads, from ad-hoc optimised containers.<br>
The implementor would also be fully responsible of making a reasonable<br>
choice to cap size.<br></blockquote><div><br></div><div>To be honest I have been wanting this for a while.  Distributed Streams has to do its own method of injecting the ComponentRegistry because we need some cache components when using indexless querying.  Instead we have to do [5] &amp; [6] which is a bit cumbersome and is not usable by end users whatsoever.</div><div><br></div><div>[5] <a href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/stream/impl/intops/IntermediateOperation.java#L27">https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/stream/impl/intops/IntermediateOperation.java#L27</a></div><div>[6] <a href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/stream/impl/LocalStreamManagerImpl.java#L251">https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/stream/impl/LocalStreamManagerImpl.java#L251</a></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The complexity is then to make sure the components are booted in the<br>
right order, and that the Externalizer instance is bound to the right<br>
scope.<br>
I realize that the Externalizer chain needs to be booted early, but<br>
the services it would look up are unlikely to need anything else so it<br>
shouldn&#39;t be hard to figure a reasonable order for bootsrapping these<br>
components.<br>
<br>
For example, one complexity would be that an Externalizer instance<br>
which is bound to cache-specific services can not be part of an<br>
externalizer chain used for a different Cache, but I believe this is<br>
in place already because of the classloader requirements.<br>
<br>
WDYT, is this feasible? I realize it makes it harder to use, but then<br>
again I expect such tricks to be applied only by internal component<br>
and expert-level extensions (i.e. Hibernate OGM, Lucene, etc..).<br>
<br>
Thanks,<br>
Sanne<br>
<br>
On 21 April 2016 at 10:35, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>&gt; wrote:<br>
&gt; For example, I&#39;d like to get some clarification on the scope of the context object:<br>
&gt;<br>
&gt; @Will, will the solution you provided in [2] deal with multiple JGroups marshalling request callbacks? Or is it only designed for a single marshalling request callback coming from JGroups tgat contains a CacheStatusResponse map? Since it&#39;s a thread local is not easy to see what&#39;s the lifespan of these instances stored in the thread local...<br>
&gt;<br>
&gt; The simplest thing would be to have a new context created for each JGroups marshalling request.<br>
&gt;<br>
&gt; However, more optimizations could be achieved from:<br>
&gt;<br>
&gt; 1. For non-transaction operations, a context per operation. So if a cache.put() results in two operations being serialized (get to return previous value, and put itself), then the context could expand those two serializations.<br>
&gt;<br>
&gt; 2. For transaction operations, a context per transaction.<br>
&gt;<br>
&gt; @Sanne, would this be enough for you? In your [4] dev post you seem to want to go beyond marshalling into how we&#39;d keep references of objects in memory, e.g. if a String is repeated in many places, have a way to centralise that storage in memory itself.<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; [4] <a href="http://lists.jboss.org/pipermail/infinispan-dev/2012-June/010925.html" rel="noreferrer" target="_blank">http://lists.jboss.org/pipermail/infinispan-dev/2012-June/010925.html</a><br>
&gt; --<br>
&gt; Galder Zamarreño<br>
&gt; Infinispan, Red Hat<br>
&gt;<br>
&gt;&gt; On 21 Apr 2016, at 10:07, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hey guys,<br>
&gt;&gt;<br>
&gt;&gt; Just a quick heads up about [1].<br>
&gt;&gt;<br>
&gt;&gt; As I was looking at the marshalling code in core, I spotted the work done for [2] and by extension [3].<br>
&gt;&gt;<br>
&gt;&gt; I can certainly see the practicality of Will&#39;s solution in [2] which fitted quite well with the current marshalling architecture, but as we rethink the entire marshalling layer in [1], I&#39;m wondering if a context-object where we can track repeated fields like Strings, Addresses... would be more suitable. For starters, we&#39;d get rid of thread locals and could be more easily exposed in other places.<br>
&gt;&gt;<br>
&gt;&gt; Any ideas or updates you have on the topic please let me know.<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt;<br>
&gt;&gt; [1] <a href="https://issues.jboss.org/browse/ISPN-6498" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/ISPN-6498</a><br>
&gt;&gt; [2] <a href="https://issues.jboss.org/browse/ISPN-4979" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/ISPN-4979</a><br>
&gt;&gt; [3] <a href="https://issues.jboss.org/browse/ISPN-2133" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/ISPN-2133</a><br>
&gt;&gt; --<br>
&gt;&gt; Galder Zamarreño<br>
&gt;&gt; Infinispan, Red Hat<br>
&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;<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>
_______________________________________________<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></blockquote></div></div>