Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 34829 invoked from network); 24 Nov 2008 03:18:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Nov 2008 03:18:58 -0000 Received: (qmail 69304 invoked by uid 500); 24 Nov 2008 03:19:07 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 69272 invoked by uid 500); 24 Nov 2008 03:19:07 -0000 Mailing-List: contact dev-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 dev@harmony.apache.org Received: (qmail 69261 invoked by uid 99); 24 Nov 2008 03:19:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Nov 2008 19:19:06 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of greensight@gmail.com designates 209.85.146.178 as permitted sender) Received: from [209.85.146.178] (HELO wa-out-1112.google.com) (209.85.146.178) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Nov 2008 03:17:42 +0000 Received: by wa-out-1112.google.com with SMTP id j5so1166719wah.4 for ; Sun, 23 Nov 2008 19:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=04Lo3ymleAOl8np7l+ubTzvayjAHHv3j64zqIHSvFFk=; b=Edw+1qBgdAFKLVY/Wf/+dPCOrgz1ZuHS/j7WwtevplJ8a94Ven5DALVgQjiFKrISKX c9V27orRAuqFqPoXu6zBoyjD8f+BLQJ22evT67An0XfGJ/c2ceaCidUG9clTzDTRtDVN 48Qu6PyGQlKPd5esz1bRMednoLGpz29Fl/FV8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=mbi8tzJVlE2b++0xTW7oyYZt/ffMUIeOjcw2EUdqXxcEfAZBj/VLeNZJeqfYG6PmQE 8xJFyEq28ALecIIV6Ezu1ROxrxnsz5LmpsHf9Ky5L4uta8xYuAKFkM6ZEocqoYPDLay6 MDXIthYpnBzS+75XlY9dxfq/E1r25RlfydVOM= Received: by 10.114.72.1 with SMTP id u1mr1685752waa.39.1227496696526; Sun, 23 Nov 2008 19:18:16 -0800 (PST) Received: by 10.114.155.11 with HTTP; Sun, 23 Nov 2008 19:18:16 -0800 (PST) Message-ID: <5e7fd1eb0811231918jdb3649cp6e57e8214512b060@mail.gmail.com> Date: Mon, 24 Nov 2008 11:18:16 +0800 From: "Jack Cai" To: dev@harmony.apache.org Subject: Re: [classlib][luni] Redundant and repeated external properties loading using ResourceBundle may degrade performance. In-Reply-To: <211709bc0811210050g287e2a78j7c44cef8317bba0f@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_54376_33179607.1227496696511" References: <4924C68E.8090104@gmail.com> <94d710af0811191832o1ad64406w957e5c8bb8e7aebe@mail.gmail.com> <49251E09.20004@gmail.com> <5e7fd1eb0811202134v36a3ecfcv888542ed2ba27afe@mail.gmail.com> <211709bc0811210050g287e2a78j7c44cef8317bba0f@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_54376_33179607.1227496696511 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Well, I think what Kevin suggests to improve the java.util.ResourceBundle impl. itself? Exception handling is not a good scenario to cite here. Web applications might be a better scenario, as they usually load a lot of (localized) messages. Fortunately many Web applications will load all the messages into memory during startup, so they won't need to read messages from disk files again and again. I guess this should be a best practise for developers in case their applications need to read many messages repeatedly. -Jack 2008/11/21 Tony Wu > Keivn > > Sorry for different idea. > > First, I dont think exception handling is a right place to talking > about performance. It's a self-contradictory story. > If you think it is a good place to improve the performance, there must > be many exceptions thrown at runtime. But I dont think there should > be, because to use try/catch as condition judgment itself is a > performance killer. My understanding is that in the most cases when we > need to get a localized message, it's time for vm to exit. And why we > should take care the performance when exit? > > Furthermore, resource bundle is designed for decoupling the localized > messages from logic. It's not a good idea to couple them again with > hashtable. You can not ask translater to modify the java source code, > compile, build, and test it ;-) > > On Fri, Nov 21, 2008 at 1:34 PM, Jack Cai wrote: > > I agree with Kevin that this might be a place that we could possibly > > improve. But we should be careful when using a cache, as it always > > introduces lots of complexity, like cache invalidation and reload. In the > > case of ResouceBundle, same thing here. What happens if the resource > files > > gets updated? This will be a common scenario in long-running Java > process, > > e.g., the JEE server environment. > > > > - Jack > > > > 2008/11/20 Jim Yu > > > >> Hi Kevin, > >> Making a cache for all the message loaded from ResourceBundle will bring > >> huge overhead if only few message would be used in an application. Only > in > >> some specific scenarios where lots of duplicate message is needed would > >> application benefit from such caching mechanism. But I don't think such > >> case > >> would be very common. Could you prove your idea by running some > benchmarks? > >> My another concern is that it doesn't make sense to use a hashtable to > >> store > >> the locale dependent message. How do you define the key for the entry? > E.g. > >> "K0046" would not be qualified since no locale info is included. And > even > >> if > >> you find a good method to solve this, the overhead would be incredible > if > >> lots of locales need to be supported for the message. > >> 2008/11/20 Kevin Zhou > >> > >> > Jim Yu wrote: > >> > > >> >> In addition, using ResourceBundle in Harmony can make the message > output > >> >> be > >> >> easily localized into different languages. And it is very convenient > to > >> >> support more locales in the future. > >> >> > >> >> 2008/11/20 Sean Qiu > >> >> > >> >> > >> >> > >> >>> We can benefit from it when exceptions are thrown many times. > >> >>> But we rarely encounter this situation in our application :) > >> >>> To save the memory, space outweigh time in this case. > >> >>> > >> >>> Correct me if I'm wrong. > >> >>> > >> >>> 2008/11/20 Kevin Zhou > >> >>> > >> >>> > >> >>> > >> >>>> Hi, > >> >>>> I read some code in LUNI module of Harmony. > >> >>>> (org.apache.harmony.luni.util.Msg/MsgHelp and > >> java.util.ResourceBundle) > >> >>>> I found that Harmony uses ResourceBundle to load messages from > >> external > >> >>>> properties file. > >> >>>> e.g. Once it requires a message "K0046", it will always use > >> >>>> ResourceBundle to go through the > >> >>>> org.apache.harmony.luni.util.ExternalMessages.properties file to > >> search > >> >>>> > >> >>>> > >> >>> it. > >> >>> > >> >>> > >> >>>> I think such redundant and repeated I/O operations may degrade our > >> >>>> performance. > >> >>>> > >> >>>> Why not use a hashtable to store all the external messages? It only > >> >>>> requires several I/O operations initially! > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>> -- > >> >>> Best Regards > >> >>> Sean, Xiao Xia Qiu > >> >>> > >> >>> China Software Development Lab, IBM > >> >>> > >> >>> > >> >>> > >> >> Hi Jim, > >> > I think that you misunderstand. > >> > I don't mean to discard using ResourceBundle for localization. > >> > I just suggest that we should use ResourceBundle to load all the > external > >> > properties and store them in a hashtable initially. > >> > Then you don't need to repeat calling ResourceBundle to scan property > >> files > >> > any more, but turn to the hashtable. This may improve performance. > >> > > >> > Hi Sean and Regis, > >> > I think that external messages are not only designed for exceptions > >> > handling. > >> > Some may also use such a useful mechanism in their applications. > >> > > >> > Let's assume that one application execute on HARMONY. > >> > As a side effect, all jars on the bootpath will be loaded to search > for > >> the > >> > ResourceBundle class the first time an external message is required. > >> > Obviously, application have to wait utill ResourceBundle class is > loaded > >> > and it successfully finds the required message, which takes seconds. > >> > > >> > Note that if we can initially load all of the external properties > before > >> > the first application class is loaded. > >> > This can provide a faster startup time and quick responses when it > >> requires > >> > any external messages. > >> > > >> > > >> > >> > >> -- > >> Best Regards, > >> Jim, Jun Jie Yu > >> > >> China Software Development Lab, IBM > >> > > > > > > -- > Tony Wu > China Software Development Lab, IBM > ------=_Part_54376_33179607.1227496696511--