Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38567

Re: JDK 9 strings very slow

From j4n bur53 <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: JDK 9 strings very slow
Date 2018-08-27 19:17 +0200
Organization albasani.net
Message-ID <pm1bo4$ea4$1@news.albasani.net> (permalink)
References (1 earlier) <a015ddd6-0716-467d-9e4a-4dfef8939afd@googlegroups.com> <plv2vr$59l$1@dont-email.me> <plv6ae$6kk$1@news.albasani.net> <pm120r$e1f$1@dont-email.me> <pm1aoo$400$1@news.albasani.net>

Show all headers | View raw


But I still see some problems with this approach,
like for example. Did Java amend equals, and like
do a check alfa.value==beta.value ?

I only find in JDK 8:

         if (this == anObject) {
             return true;
         }
         if (anObject instanceof String) {
             String anotherString = (String)anObject;
             int n = value.length;
             if (n == anotherString.value.length) {
                 char v1[] = value;
                 char v2[] = anotherString.value;
                 int i = 0;
                 while (n-- != 0) {
                     if (v1[i] != v2[i])
                         return false;
                     i++;
                 }
                 return true;
             }
         }
         return false;

But if more Strings are deduplicated,
and as I understand then only the char[]
is elemeninated, the JEP writes:

"When deduplicating, a lookup is made in this
table to see if there is already an identical
character array somewhere on the heap."

So the above could profit from an
additional code line:

    if (value==anotherString.value)
         return true;

Maybe this was done in JDK 9. Further my code
could profit from more deduplication, since
the JEP method doesn't deduplicate the

object gutter. There will be still space
needed for the Sring object around the
character array. And I have a use case

where I compare a lot of identical objects.
Cant help it at the moment making the code
simpler, but somehow it happens that have an

index key, and then a redundant check of the
same key over a collection. So all these checks
could profit if I manage to go into the

branch if (this == anObject) of the String
equality test. Baha, lets see what can be done,
I have an idea how to deduplicate the object

gutter via the index I have anyway and
this would also work for Android... Ha Ha

Bye

j4n bur53 schrieb:
> Ok, I guess I will try the option:
> 
>     PrintStringDeduplicationStatistics
> 
> To see what is happening...
> 
> Eric Sosman schrieb:
>> On 8/26/2018 5:33 PM, j4n bur53 wrote:
>>> Hi,
>>>
>>> Which kind of algorithm was implemented in
>>> 8u20 ? There were like 2-4 different
>>> approaches mentioned in the Change.
>>
>>      Do you mean the approaches mentioned in the "Alternatives"
>> section?  It appears to me that they are listed merely to show
>> that they were considered -- and each is accompanied by a "Why
>> this wouldn't be good" summary.  That is, the "Alternatives"
>> are the *rejected* approaches.
>>
> 

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-07-27 15:47 +0200
  Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-07-27 15:56 +0200
    Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-07-27 16:21 +0200
  Re: JDK 9 strings very slow Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-07-27 10:11 -0400
    Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-07-27 16:23 +0200
      Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-07-27 16:25 +0200
  Re: JDK 9 strings very slow bursejan@gmail.com - 2018-08-26 09:44 -0700
    Re: JDK 9 strings very slow Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-26 16:36 -0400
      Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-08-26 23:33 +0200
        Re: JDK 9 strings very slow Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-27 10:31 -0400
          Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-08-27 19:01 +0200
            Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-08-27 19:17 +0200
              Re: JDK 9 strings very slow Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-08-27 13:32 -0400
                Re: JDK 9 strings very slow bursejan@gmail.com - 2018-08-27 10:49 -0700
                Re: JDK 9 strings very slow bursejan@gmail.com - 2018-08-30 18:56 -0700
                Re: JDK 9 strings very slow bursejan@gmail.com - 2018-08-31 00:29 -0700
                Re: JDK 9 strings very slow j4n bur53 <janburse@fastmail.fm> - 2018-08-31 09:56 +0200

csiph-web