<br><div class="gmail_quote">On Tue, Oct 23, 2012 at 6:09 PM, Galder Zamarreño <span dir="ltr"><<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On Oct 23, 2012, at 3:03 PM, Dan Berindei <<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>> wrote:<br>
<br>
> On Tue, Oct 23, 2012 at 3:27 PM, Galder Zamarreño <<a href="mailto:galder@redhat.com">galder@redhat.com</a>> wrote:<br>
><br>
> On Oct 22, 2012, at 10:13 AM, Dan Berindei <<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>> wrote:<br>
><br>
> > On Mon, Oct 22, 2012 at 9:25 AM, Galder Zamarreño <<a href="mailto:galder@redhat.com">galder@redhat.com</a>> wrote:<br>
> ><br>
> > On Oct 19, 2012, at 6:28 PM, Dan Berindei <<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>> wrote:<br>
> ><br>
> > > Galder, what JDK are you using?<br>
> ><br>
> > java version "1.6.0_35"<br>
> > Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)<br>
> > Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)<br>
> ><br>
> > > OpenJDK 1.7 uses EmptyIterator.EMPTY_ITERATOR since 2007:<br>
> > ><br>
> > > <a href="http://hg.openjdk.java.net/jdk7/jdk7/jdk/annotate/37a05a11f281/src/share/classes/java/util/Collections.java" target="_blank">http://hg.openjdk.java.net/jdk7/jdk7/jdk/annotate/37a05a11f281/src/share/classes/java/util/Collections.java</a><br>
> ><br>
> > Good that the figured out this is non-sense.<br>
> ><br>
> > > I don't have JDK 1.6 sources on hand to check, but I don't think it's worth optimizing for such an old version anyway.<br>
> ><br>
> > Why not? We support JDK 1.6, so nothing stops them from running it.<br>
> ><br>
> > Until we baseline on JDK7 (or 8), I'd leave it in.<br>
> ><br>
> ><br>
> > My point was that it is a really big change, and further it imposes a burden on anyone writing code with collections in Infinispan. I'm sure we will spend non-trivial amounts of time during reviews pointing out places there the author should have used InfinispanCollections instead of Collections…<br>
><br>
> It's part of your job as pull request handler to check for these things, and many other bad practices that can be carried out… I don't see why is this different to other.<br>
><br>
> What's missing here is a check list of things we should be checking for when we handle pull requests.<br>
><br>
> I volunteer to do one once I got 2LC out of the way.<br>
><br>
> > I would be willing to go for it if a benchmark showed a significant increase in performance after the change, but you didn't mention any benchmarks, so I guessed that you didn't see a big difference…<br>
><br>
> It's doesn't affect performance directly, but indirectly.<br>
><br>
> It's about memory consumption. If you use less memory to do the same work, less burden on GC, and less time spent doing GC.<br>
><br>
><br>
> How much memory does Infinispan allocate for each put/get and how much of that is used by these iterators? Since we already use null instead of empty collections in lots of places, I bet it's not even 0.01%.<br>
<br>
</div>The coding change is based on information gathered via <a href="https://issues.jboss.org/browse/ISPN-2414" target="_blank">https://issues.jboss.org/browse/ISPN-2414</a> - feel free to browse through it and I can upload the snapshot if needed.<br>
<div class="im"><br></div></blockquote><div><br>Sorry, I only read the subject line of ISPN-2414 - I thought it was a different issue because these iterators are transient so they wouldn't count for Infinispan's memory usage.<br>
<br>1.7% of the memory allocations just for the EmptySet iterator does sound like a lot, did you also compare performance before and after your change?<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
> So yeah, these iterators do have an impact, but that impact is negligible, whereas the impact on the developers and reviewers to implement this change is not going to be negligible.<br>
<br>
</div>Impact on developers/reviewers? Aren't you exagerating a bit? :)<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br>Well, I was convinced that the impact of these changes on performance was 0, and anything is greater than 0, even doing a search for 'Collections.empty' in the PR diff.<br>
<br>I was probably overreacting, but I just wouldn't want us to end up with rules like 'all method parameters must be final' ;-)<br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
> Of course, I might be wrong and this patch might improve throughput for local caches by 1%, but based on what I know so far that's not the case.<br>
><br>
><br>
> ><br>
> ><br>
> > ><br>
> > > Cheers<br>
> > > Dan<br>
> > ><br>
> > ><br>
> > > On Fri, Oct 19, 2012 at 5:50 PM, Vladimir Blagojevic <<a href="mailto:vblagoje@redhat.com">vblagoje@redhat.com</a>> wrote:<br>
> > > Cool! Did not know about this! Is this original idea or others are<br>
> > > already doing this?<br>
> > > On 12-10-19 8:31 AM, Galder Zamarreño wrote:<br>
> > > > Hi all,<br>
> > > ><br>
> > > > Re: <a href="https://github.com/galderz/infinispan/commit/0609207d13216de81d77ff51dc20652ce270c635" target="_blank">https://github.com/galderz/infinispan/commit/0609207d13216de81d77ff51dc20652ce270c635</a><br>
> > > ><br>
> > > > Please avoid using these JDK methods where possible. I've created alternative versions in InfinispanCollections util class that provide a better implementation.<br>
> > > ><br>
> > > > The problem with the JDK versions is that even if these collections are immutable, if you wanna iterate them (i.e. for(X : emptySet) ), they'll create a brand new Iterator every time they're looped, and that generates useless garbage.<br>
> > > ><br>
> > > > The InfinispanCollections versions of emptyX will return a constant singleton iterator which avoids this problem, and avoids the need for client code to check if the collection is empty before looping.<br>
> > > ><br>
> > > > Cheers,<br>
> > > > --<br>
> > > > Galder Zamarreño<br>
> > > > <a href="mailto:galder@redhat.com">galder@redhat.com</a><br>
> > > > <a href="http://twitter.com/galderz" target="_blank">twitter.com/galderz</a><br>
> > > ><br>
> > > > Project Lead, Escalante<br>
> > > > <a href="http://escalante.io" target="_blank">http://escalante.io</a><br>
> > > ><br>
> > > > Engineer, Infinispan<br>
> > > > <a href="http://infinispan.org" target="_blank">http://infinispan.org</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>
><br>
><br>
> --<br>
> Galder Zamarreño<br>
> <a href="mailto:galder@redhat.com">galder@redhat.com</a><br>
> <a href="http://twitter.com/galderz" target="_blank">twitter.com/galderz</a><br>
><br>
> Project Lead, Escalante<br>
> <a href="http://escalante.io" target="_blank">http://escalante.io</a><br>
><br>
> Engineer, Infinispan<br>
> <a href="http://infinispan.org" target="_blank">http://infinispan.org</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>
><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>
<br>
<br>
--<br>
Galder Zamarreño<br>
<a href="mailto:galder@redhat.com">galder@redhat.com</a><br>
<a href="http://twitter.com/galderz" target="_blank">twitter.com/galderz</a><br>
<br>
Project Lead, Escalante<br>
<a href="http://escalante.io" target="_blank">http://escalante.io</a><br>
<br>
Engineer, Infinispan<br>
<a href="http://infinispan.org" target="_blank">http://infinispan.org</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>
</div></div></blockquote></div><br>