You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Andrew Cornwall (JIRA)" <ji...@apache.org> on 2008/07/11 22:46:31 UTC

[jira] Created: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

[classlib][pack200]CPUTF8.hashCode() is slow
--------------------------------------------

                 Key: HARMONY-5907
                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
             Project: Harmony
          Issue Type: Improvement
    Affects Versions: 5.0M6
         Environment: Latest pack200
            Reporter: Andrew Cornwall


The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613388#action_12613388 ] 

Andrew Cornwall commented on HARMONY-5907:
------------------------------------------

I would suggest at least one change: have the generateHashCode() method assign the cachedHashCode. Right now, users will have to write code like this:

// I want to assign the hashCode
cachedHashCode = generateHashCode();

It's possible (and in fact I did the following) when updating a class:

// I want to assign the hashCode
generateHashCode();
// at this point hashCodeComputed == true, but cachedHashCode is not yet assigned.


> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613401#action_12613401 ] 

Aleksey Shipilev commented on HARMONY-5907:
-------------------------------------------

Yep, Andrew, you're right about generateHashCode() contract. It should be 

private void generateHashCode() {
    if (hashCodeComputed) return;
    cachedHashCode = { .... };
    hashCodeComputed = true;
}

public int hashCode() {
    generateHashCode();
    return cachedHashCode;
}

Can you take the honor of updating the patch?

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Sian January (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sian January resolved HARMONY-5907.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 5.0M7

Applied Andrew's patch at r676866. Please check that it was applied as expected.

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>             Fix For: 5.0M7
>
>         Attachments: main.patch, pack200-hashcodes-v1.patch, pack200-hashcodes-v2.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall updated HARMONY-5907:
-------------------------------------

    Attachment: main.patch

main.patch includes change to CPUTF8.java


> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>         Attachments: main.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksey Shipilev updated HARMONY-5907:
--------------------------------------

    Attachment: pack200-hashcodes-v1.patch

pack200-hashcodes-v1.patch
Covers top classes' hashcodes.

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall closed HARMONY-5907.
------------------------------------


Patch applied as expected. Thanks!

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>             Fix For: 5.0M7
>
>         Attachments: main.patch, pack200-hashcodes-v1.patch, pack200-hashcodes-v2.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall updated HARMONY-5907:
-------------------------------------

    Attachment: pack200-hashcodes-v2.patch

Patch with update to generateHashCode as specified above. I also updated ClassFileEntry and ByteCode so they use Object.hashCode instead of computing one manually.

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch, pack200-hashcodes-v2.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Sian January (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sian January reassigned HARMONY-5907:
-------------------------------------

    Assignee: Sian January

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612992#action_12612992 ] 

Aleksey Shipilev commented on HARMONY-5907:
-------------------------------------------

It would be great to review all hashcode implementations around pack200. I see ClassFileEntry.hashcode() as good example.

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>         Attachments: main.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613360#action_12613360 ] 

Andrew Cornwall commented on HARMONY-5907:
------------------------------------------

(And I see in dev that Aleksey had reasons for this - I'll check his changes and see how they do.)

> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5907) [classlib][pack200]CPUTF8.hashCode() is slow

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613359#action_12613359 ] 

Andrew Cornwall commented on HARMONY-5907:
------------------------------------------

Some of these classes are set in the constructor and then never altered. In these classes, it should be possible to generateHashCode() in the constructor, meaning we don't need to check for hashcodeComputed in the hashCode() method.


> [classlib][pack200]CPUTF8.hashCode() is slow
> --------------------------------------------
>
>                 Key: HARMONY-5907
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5907
>             Project: Harmony
>          Issue Type: Improvement
>    Affects Versions: 5.0M6
>         Environment: Latest pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch, pack200-hashcodes-v1.patch
>
>
> The unpack process spends a lot of time doing CPUTF8.hashCode() - which does String.hashCode(). We can save about 1.5 seconds of my 39 second test case (about 4%) by caching the hashCode. (I thought we did this before - or maybe I dreamt it?)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.