Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 79104 invoked from network); 28 Mar 2008 17:26:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Mar 2008 17:26:53 -0000 Received: (qmail 76983 invoked by uid 500); 28 Mar 2008 17:26:52 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 76968 invoked by uid 500); 28 Mar 2008 17:26:52 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 76955 invoked by uid 99); 28 Mar 2008 17:26:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Mar 2008 10:26:52 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Mar 2008 17:25:58 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 70113234C0B2 for ; Fri, 28 Mar 2008 10:24:24 -0700 (PDT) Message-ID: <1420550059.1206725064457.JavaMail.jira@brutus> Date: Fri, 28 Mar 2008 10:24:24 -0700 (PDT) From: "Alexei Fedotov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-4569) [classlib][performance] Ineffecient manifest parsing results in slowdown when debugging java code In-Reply-To: <10786034.1185808553802.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-4569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12583100#action_12583100 ] Alexei Fedotov commented on HARMONY-4569: ----------------------------------------- Tim, That's unbelievable. I'm grateful for your effort. Could you please help me to understand why you restored unreadable localization identifiers? With this change my removal of explanatory comments around them made code less understandable. > [classlib][performance] Ineffecient manifest parsing results in slowdown when debugging java code > ------------------------------------------------------------------------------------------------- > > Key: HARMONY-4569 > URL: https://issues.apache.org/jira/browse/HARMONY-4569 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Gregory Shimansky > Assignee: Tim Ellison > Attachments: ByteBuffer.java, ExposedByteArrayInputStream.java, methodee-stack.cpp, methodee.cpp, remove_writes.patch, remove_writes_25032008.patch, remove_writes_todo.patch, remove_writes_todo_1.patch, remove_writes_todo_completed.patch, ThreadLocalCache.java > > > I've reported this already some time ago [1], but since it wasn't noticed I decided to create a bug report. > To run a hello world class which contains only 1 method takes 319046 method calls on Harmony. Out of them 291637 method calls are the calls that happen when Java class loader tries to find Hello.class and 27409 are what it takes for classlib to startup. > I've found these numbers using two simple JVMTI agents that I wrote some time ago. First one [2] counts all MethodEnter events and outputs method names to log file. Second one [3] monitors a particular method and writes down a stack trace to the log file. It should be noted that MethodEnter event according to specification is sent by VM only in LIVE phase, that is after classlib startup, so to find out the overall number of method calls I've used debug version of DRLVM with an additional argument -Xtrace:jvmti.event.method.entry:log which wrote down *all* of the calls to Java method while executing the application. > Parsing the logs for statistics can be done with the following command: > cat method_entry.log | sort | uniq -c | sort -nr > method_entry.log-sorted > It creates a file with the number that each method was called. The absolute champion since my post in [1] still remains the method Ljava/io/ByteArrayOutputStream;.write(I)V, it is called 131114 times. Using second agent [3] I've found out that the most popular stack trace for calling ByteArrayOutputStream;.write looks like this (please note that numbers at the ends of the lines are not line numbers, these are the bytecode numbers): > Ljava/io/ByteArrayOutputStream;.write(I)V:0 > Ljava/util/jar/InitManifest;.nextChunk(Ljava/io/InputStream;Ljava/util/List;)[B:308 > Ljava/util/jar/InitManifest;.(Ljava/io/InputStream;Ljava/util/jar/Attributes;Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;)V:385 > Ljava/util/jar/Manifest;.read(Ljava/io/InputStream;)V:18 > Ljava/util/jar/Manifest;.(Ljava/io/InputStream;Z)V:43 > Ljava/util/jar/JarFile;.getManifest()Ljava/util/jar/Manifest;:90 > Ljava/net/URLClassLoader;.createURLJarHandler(Ljava/net/URL;)Ljava/net/URLClassLoader$URLHandler;:141 > Ljava/net/URLClassLoader;.makeNewHandler()V:64 > Ljava/net/URLClassLoader;.getHandler(I)Ljava/net/URLClassLoader$URLHandler;:24 > Ljava/net/URLClassLoader;.findClassImpl(Ljava/lang/String;)Ljava/lang/Class;:82 > Ljava/net/URLClassLoader$4;.run()Ljava/lang/Class;:8 > Ljava/net/URLClassLoader$4;.run()Ljava/lang/Object;:1 > Ljava/security/AccessController;.doPrivilegedImpl(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;:79 > Ljava/security/AccessController;.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;:16 > Ljava/net/URLClassLoader;.findClass(Ljava/lang/String;)Ljava/lang/Class;:13 > Ljava/lang/ClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;:80 > Ljava/lang/ClassLoader$SystemClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;:65 > Ljava/lang/ClassLoader;.loadClass(Ljava/lang/String;)Ljava/lang/Class;:3 > This stack trace occurs 123029 number of times, about 8000 times ByteArrayOutputStream;.write is called from InitManifest class with a bit different stack trace, but all of the calls to write occur from this class. It seems that InitManifest code copies memory by bytes and there is quite a lot of the memory that is copied. This may not be a big problem in the normal execution of Java application because JIT usually inlines such hot methods. Although it is still inefficient, it may be not a big performance hit (actually this should be checked). > But when trying to debug Java code, DRLVM uses JET, which doesn't inline any methods. It has to execute all of them and all of those calls to ByteArrayOutputStream;.write are executed on startup of the application. It takes several minutes to get to the point of executing the actual user program. > [1] http://thread.gmane.org/gmane.comp.java.harmony.devel/21104/focus=21133 see also messages posted in this subthread by me > [2] http://people.apache.org/~gshimansky/methodee.cpp > [3] http://people.apache.org/~gshimansky/methodee-stack.cpp -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.