harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Cornwall (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-5900) [classlib][pack200] CpBands.parseCpSignature(Ljava/io/InputStream;) is hot
Date Mon, 07 Jul 2008 19:40:31 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-5900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611305#action_12611305
] 

Andrew Cornwall commented on HARMONY-5900:
------------------------------------------

Good question - I didn't write the code, and I'm hoping Sian did :-) I tried a HashMap with
my SegmentConstantPoolArrayCache code above, but that didn't seem to give me any speedup.
(No matter whether I used it for all arrays or just large arrays, the time it took was about
the same as the time for a linear search - hence my suspicion that many arrays are searched
infrequently. Or I might have made an error because I'm not too familiar with CpBands other
than as a consumer.)


> [classlib][pack200] CpBands.parseCpSignature(Ljava/io/InputStream;) is hot
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-5900
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5900
>             Project: Harmony
>          Issue Type: Wish
>          Components: Classlib
>    Affects Versions: 5.0M6
>         Environment: All Pack200 HEAD
>            Reporter: Andrew Cornwall
>
> The method org/apache/harmony/unpack200/CpBands.parseCpSignature(Ljava/io/InputStream;)
appears to be very hot. I tried initially to optimize it by caching some of its arrays:
>     static void clearArrayCache() {
>     	arrayCache = new SegmentConstantPoolArrayCache();
>     }
>     
>     private static SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
>     
>     private int search(String[] array, String string) {
>     	if(array.length > 30) {
>     		List indexes = arrayCache.indexesForArrayKey(array, string);
>     		if (indexes.size() == 0) {
>     			return -1;
>     		}
>     		return ((Integer)indexes.get(0)).intValue();
>     	} else {
>     		for (int i = 0; i < array.length; i++) {
>     			if(array[i].equals(string)) {
>     				return i;
>     			}
>     		}
>     		return -1;
>     	}
>     }
> ... but that didn't appear to increase performance. (Maybe all the searches are done
once?)
> Any ideas how to tune parseCpSignature to get it faster?

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


Mime
View raw message