Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1573A18BC9 for ; Wed, 3 Feb 2016 16:05:08 +0000 (UTC) Received: (qmail 35340 invoked by uid 500); 3 Feb 2016 16:04:51 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 35268 invoked by uid 500); 3 Feb 2016 16:04:51 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 35257 invoked by uid 99); 3 Feb 2016 16:04:51 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2016 16:04:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4260918027E for ; Wed, 3 Feb 2016 16:04:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.981 X-Spam-Level: X-Spam-Status: No, score=0.981 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 3sFhAcnzu8VJ for ; Wed, 3 Feb 2016 16:04:42 +0000 (UTC) Received: from vms173021pub.verizon.net (vms173021pub.verizon.net [206.46.173.21]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id ED17A20D14 for ; Wed, 3 Feb 2016 16:04:41 +0000 (UTC) Received: from Christophers-iMac.local ([71.127.40.115]) by vms173021.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0O1Z00JE1BBRU0E0@vms173021.mailsrvcs.net> for dev@tomcat.apache.org; Wed, 03 Feb 2016 10:04:40 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=WcjxEBVX c=1 sm=1 tr=0 a=tVXBnewmVzifmTgg5+7jYA==:117 a=IkcTkHD0fZMA:10 a=jFJIQSaiL_oA:10 a=j4nzMFrpAAAA:8 a=QfKxxUxMAAAA:8 a=OxTMMYIdtmk5knDhHdoA:9 a=QEXdDO2ut3YA:10 Subject: Re: ELParser fiel of type LookaheadSuccess extends Error To: Tomcat Developers List References: <56B22160.8090703@kippdata.de> From: Christopher Schultz Message-id: <56B22517.2030502@christopherschultz.net> Date: Wed, 03 Feb 2016 11:04:39 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <56B22160.8090703@kippdata.de> Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rainer, On 2/3/16 10:48 AM, Rainer Jung wrote: > Hi there, > > ELParser has a field named jj_ls of type LookaheadSuccess which > extends Error. It is created during each instantiation of an > ELParser object. Creating an Error is quite slow, because e.g. it > calls java.lang.Throwable.fillInStack() during init. > > This jj_ls is only used once in jj_scan_token() where it is thrown > in case of certain condition, see line 2985: > > 2968 private boolean jj_scan_token(int kind) { 2969 if (jj_scanpos > == jj_lastpos) { 2970 jj_la--; 2971 if (jj_scanpos.next == null) { > 2972 jj_lastpos = jj_scanpos = jj_scanpos.next = > token_source.getNextToken(); 2973 } else { 2974 jj_lastpos = > jj_scanpos = jj_scanpos.next; 2975 } 2976 } else { 2977 jj_scanpos > = jj_scanpos.next; 2978 } 2979 if (jj_rescan) { 2980 int i = 0; > Token tok = token; 2981 while (tok != null && tok != jj_scanpos) { > i++; tok = tok.next; } 2982 if (tok != null) > jj_add_error_token(kind, i); 2983 } 2984 if (jj_scanpos.kind != > kind) return true; 2985 if (jj_la == 0 && jj_scanpos == jj_lastpos) > throw jj_ls; 2986 return false; 2987 } > > This is generated code and it is the only place were jj_ls is being > used. > > I noticed this situation because I'm doing a performance analysis > of an application. I wonder whether creating this jj_ls for each > new ELParser instance in advance is the right thing to do. One > could also put the burden on the usage side, e.g. generating it > when it is needed to be thrown. Unfortunately I don't know enough > about the typical runtime details of ELParser. E.g. it might be > that typically only few instances of it are created because they > get reused (which doesn't seem to be the case, we only create and > use it method local in createNodeInternal.createNodeInternal()) or > their results get cached (which seems to be the case). > > I'll have a look at how effective the caching is for the > application in question, but I'd be interested if there is an > opinion whether the pattern to create the Error object eagerly when > creating the ELParser object seems appropriate. No idea currently, > how one would change it Is the stack trace of the current implementation important when that Error (subclass) is thrown? If the stack trace is important to be filled-in at that earlier time, then this is a complex issue. If nobody cares what the stack trace says, I'm +1 for only instantiating the Error when it needs to be thrown. - -chris -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlayJRcACgkQ9CaO5/Lv0PDawQCfbvmI12paCRrzqh4sArOg+ImQ MHIAoIMAiGTtFXzL/GEYhHLbLvVF1uVY =tfnY -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org