Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 34559 invoked from network); 22 Jul 2010 05:08:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Jul 2010 05:08:58 -0000 Received: (qmail 22766 invoked by uid 500); 22 Jul 2010 05:08:58 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 22524 invoked by uid 500); 22 Jul 2010 05:08:55 -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 22515 invoked by uid 99); 22 Jul 2010 05:08:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 05:08:54 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of clraychen@gmail.com designates 209.85.214.177 as permitted sender) Received: from [209.85.214.177] (HELO mail-iw0-f177.google.com) (209.85.214.177) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 05:08:46 +0000 Received: by iwn40 with SMTP id 40so9303353iwn.36 for ; Wed, 21 Jul 2010 22:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=zrwx4lNKhB+HwDlKn7JkzlWjcaqpnL1zTVQ2abuRa68=; b=EEyUQE4KSiOHHciEdrzPp1Jq+4wMYZfmhutWk18qtnqeA+D1/ZIXx5ue5HnIHs6CDr qLt06KEOxslBYEjBVr2/VxnQaG3MMRSrNDFFCgeO8B1MXUDiSNgAdFWR9nKel/U+NKCb abxevOEg+h9Gh5KHLZdIzuDpdzKaUJKWcv2AU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=xsCdJRL2tEH/r0dYBeHZvz64uWX9UR+Ivo25vfD/uGEuAQfOv5nURnh7WCWMXkwdfF 7pgDkMEi9QVKN/vORuFS9DgLZfjArPHjdexRUVXjTyTdYEk14H75SAGNSlXQqh6oNQu0 rLOoU5diV49SGprrWz9GQstdeuZcfpwkeIjoQ= MIME-Version: 1.0 Received: by 10.231.150.7 with SMTP id w7mr1370506ibv.14.1279775245629; Wed, 21 Jul 2010 22:07:25 -0700 (PDT) Received: by 10.231.150.19 with HTTP; Wed, 21 Jul 2010 22:07:25 -0700 (PDT) Date: Thu, 22 Jul 2010 13:07:25 +0800 Message-ID: Subject: Security Performance issue From: Ray Chen To: dev@harmony.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi All, I found that our security implementation is much slower than RI's when get an algorithm instance. I have done some investigation and found that most time are consumed on loading and initialising providers. Following is the test cases and results to show this problem. RI5 | RI6 | Harmony5 | Harmony6 Testcase1[1] 78ms | 90~100ms | 450ms | 475~490ms Testcase2[2] 75ms | 85~91ms | | Testcase3[3] | | 447~455ms | 470~490ms Testcase4[4] 9~10ms | 6ms | | Testcase5[5] | | 448~462ms | 479~501ms Testcase6[6] 9ms | 8~10ms | 448~459ms | 481~490ms From[1], we can see our implementation is much slower than RI's when loading all the providers. Compare [2] & [3], both loading JSSE provider, our implementation is much slower. Compare [2] & [4], the time differs, which means RI can load providers one by one. Compare [1],[3] & [5], we can see our implementation consumes almost same time whether it loads one or more providers. Form[6], I guess RI knows what services a provider provides so that it can just pick up the providers the application need. If you look into the Services.java, you will find that our implementation will load all the providers when this class is loaded even this application does NOT need some of providers. Then it put all the providers and services into a cache which can be called "pre-loading". Base on the above investigation, I suggest to change the "pre-loading" to "lazy-loading" if possible which means only loading necessary providers, no more, no less. But I found that it is very hard to achieve this target, because we don't know what services a provider provides before we load the provider. I don't know what RI does to achieve this. Maybe we can store the map relationships between these default providers and services to a file or internal cache table? Any comments or suggestions? Jimmy, Kevin, I talked to you about this issue before, feel free to fix me if anything is wrong. Or you can give more information about this issue. [1] public static void main(String[] args) { long start = System.currentTimeMillis(); for (Provider p : Security.getProviders()) { p.getServices(); } System.out.println(System.currentTimeMillis() - start); } [2] public static void main(String[] args) throws NoSuchAlgorithmException { long start = System.currentTimeMillis(); Security.getProvider("SUNJSSE"); System.out.println(System.currentTimeMillis() - start); } [3] public static void main(String[] args) throws NoSuchAlgorithmException { long start = System.currentTimeMillis(); Security.getProvider("HarmonyJSSE"); System.out.println(System.currentTimeMillis() - start); } [4] public static void main(String[] args) throws NoSuchAlgorithmException { long start = System.currentTimeMillis(); Security.getProvider("SUN"); System.out.println(System.currentTimeMillis() - start); } [5] public static void main(String[] args) throws NoSuchAlgorithmException { long start = System.currentTimeMillis(); Security.getProvider("BC"); System.out.println(System.currentTimeMillis() - start); } [6] public static void main(String[] args) throws NoSuchAlgorithmException { long start = System.currentTimeMillis(); MessageDigest.getInstance("SHA-1"); System.out.println(System.currentTimeMillis() - start); } -- Regards, Ray Chen