lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Willnauer <simon.willna...@googlemail.com>
Subject Re: svn commit: r1141510 - /lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/UnsafeByteArrayOutputStream.java
Date Thu, 30 Jun 2011 13:40:01 GMT
On Thu, Jun 30, 2011 at 3:26 PM, Uwe Schindler <uwe@thetaphi.de> wrote:
> We had an issue about this with FST's array growing in Mike's code, in facts ist *much*
slower for generic Arrays' T[] copyOf(T[]...), with T extends Object (uses slow reflection).
>
> For primitives it can only get faster in later JVMs, this is why we want to change all
ArrayUtils.grow() to use this (and we don’t have a generic one there for above reason).

+1 - I don't see why this would be any slower... if we can get
improvements we should go for it. The issues and bugreports are all
for non-primitive copyOf methods so I don't see how this should affect
us

simon
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
>> -----Original Message-----
>> From: dawid.weiss@gmail.com [mailto:dawid.weiss@gmail.com] On Behalf
>> Of Dawid Weiss
>> Sent: Thursday, June 30, 2011 3:11 PM
>> To: dev@lucene.apache.org
>> Subject: Re: svn commit: r1141510 -
>> /lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsafe
>> ByteArrayOutputStream.java
>>
>> Arrays.copyOf(primitive) is actually System.arraycopy by default. If intrinsics
>> are used it can only get faster. For object types it will probably be a bit slower
>> for -client because of a runtime check for the component type.
>>
>> Dawid
>>
>> On Thu, Jun 30, 2011 at 3:05 PM, Robert Muir <rcmuir@gmail.com> wrote:
>> > because on windows 32bit at least, -client is still the default on
>> > most jres out there.
>> >
>> > i realize people don't care about -client, but i will police
>> > foo[].clone() / arrays.copyOf etc to prevent problems.
>> >
>> > There are comments about this stuff on the relevant bug reports
>> > (oracle's site is down, sorry) linked to this issue.
>> > https://issues.apache.org/jira/browse/LUCENE-2674
>> >
>> > Sorry, I don't think we should use foo[].clone() / arrays.copyOf, I
>> > think we should always use arraycopy.
>> >
>> > On Thu, Jun 30, 2011 at 8:55 AM, Simon Willnauer
>> > <simon.willnauer@googlemail.com> wrote:
>> >> hmm are you concerned about the extra Math.min that happens in the
>> >> copyOf method?
>> >> I don't how that relates to "intrinsic" and java 1.7
>> >>
>> >> I don't have strong feelings here just checking if you mix something
>> >> up in the comment you put there... I am happy to keep the old and now
>> >> current code
>> >>
>> >> simon
>> >>
>> >> On Thu, Jun 30, 2011 at 2:42 PM,  <rmuir@apache.org> wrote:
>> >>> Author: rmuir
>> >>> Date: Thu Jun 30 12:42:17 2011
>> >>> New Revision: 1141510
>> >>>
>> >>> URL: http://svn.apache.org/viewvc?rev=1141510&view=rev
>> >>> Log:
>> >>> LUCENE-3239: remove use of slow Arrays.copyOf
>> >>>
>> >>> Modified:
>> >>>
>> >>>
>> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsaf
>> >>> eByteArrayOutputStream.java
>> >>>
>> >>> Modified:
>> >>>
>> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsaf
>> >>> eByteArrayOutputStream.java
>> >>> URL:
>> >>>
>> http://svn.apache.org/viewvc/lucene/dev/trunk/modules/facet/src/java
>> >>>
>> /org/apache/lucene/util/UnsafeByteArrayOutputStream.java?rev=1141510
>> >>> &r1=1141509&r2=1141510&view=diff
>> >>>
>> ==========================================================
>> ==========
>> >>> ==========
>> >>> ---
>> >>>
>> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsaf
>> >>> eByteArrayOutputStream.java (original)
>> >>> +++
>> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/U
>> >>> +++ nsafeByteArrayOutputStream.java Thu Jun 30 12:42:17 2011
>> >>> @@ -2,7 +2,6 @@ package org.apache.lucene.util;
>> >>>
>> >>>  import java.io.IOException;
>> >>>  import java.io.OutputStream;
>> >>> -import java.util.Arrays;
>> >>>
>> >>>  /**
>> >>>  * Licensed to the Apache Software Foundation (ASF) under one or
>> >>> more @@ -72,7 +71,11 @@ public class UnsafeByteArrayOutputStream
>> >>>   }
>> >>>
>> >>>   private void grow(int newLength) {
>> >>> -    buffer = Arrays.copyOf(buffer, newLength);
>> >>> +    // It actually should be: (Java 1.7, when its intrinsic on all
>> >>> + machines)
>> >>> +    // buffer = Arrays.copyOf(buffer, newLength);
>> >>> +    byte[] newBuffer = new byte[newLength];
>> >>> +    System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
>> >>> +    buffer = newBuffer;
>> >>>   }
>> >>>
>> >>>   /**
>> >>>
>> >>>
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For
>> >> additional commands, e-mail: dev-help@lucene.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For
>> > additional commands, e-mail: dev-help@lucene.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional
>> commands, e-mail: dev-help@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message