Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8E3D32009C5 for ; Mon, 16 May 2016 14:01:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8B426160A16; Mon, 16 May 2016 12:01:34 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D52491609B0 for ; Mon, 16 May 2016 14:01:33 +0200 (CEST) Received: (qmail 35657 invoked by uid 500); 16 May 2016 12:01:33 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 35647 invoked by uid 99); 16 May 2016 12:01:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 May 2016 12:01:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6298FC07E9 for ; Mon, 16 May 2016 12:01:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.098 X-Spam-Level: X-Spam-Status: No, score=0.098 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 23nr_jnqCMcl for ; Mon, 16 May 2016 12:01:28 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 28E655F1F5 for ; Mon, 16 May 2016 12:01:28 +0000 (UTC) Received: from [192.168.1.3] ([92.224.23.28]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0M6SJX-1bmfb21no3-00yUGW for ; Mon, 16 May 2016 14:01:27 +0200 Subject: Re: Improve Groovy class loading performance and memory management To: dev@groovy.apache.org References: <57351E2A.2070304@span.ch> <573835A4.2060301@span.ch> <5738517B.5010301@gmx.org> <5739A4EF.1020002@span.ch> From: Jochen Theodorou Message-ID: <5739B695.5070408@gmx.org> Date: Mon, 16 May 2016 14:01:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <5739A4EF.1020002@span.ch> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:lhzTlOrfME/Q3Bz4EbAk5uwB5BZfi+NXuiNeBmKzWncKh3yVe2B mLFw8OlbICYK76CLtKLvGL5a32QOZz9ulZ0l7VTSHY8bAuNxtVn9qrIWuN+4U/arSkXjwZE eH76eF+smLOLt5dBw1hD4yAdcwwTp65c9+22IEXPtJ5NFyChw20fTWC2vMcv7c/Vbqn2iy+ 1Zc23lVGfasYFYJpAimxw== X-UI-Out-Filterresults: notjunk:1;V01:K0:z9HegdJrFjM=:9k7eQFk7cvtMrOjOoWL75B xwPfsJ/TXFUh8pVxCuAMBcjJEEP7ugoFbAE1WgCWKA6K3v3iQwWwYLMk9HY+QZnLrbmtrwBvN iHZCrsSNayB9Mha/9NzMiTE4Qmi5dBF0KJdHfSu8Qwjv/13eaLxZ7zGQmLJjMLT6tv7ug9DOO +hWwkjfaK+Wtt+FEUoplnXYJ/ArJdxdguCg7tYWDrO/5ByCb/Pl3NfuBri4Za7BpeeELvjUa5 k/mjjIvDMCcdpP16PLVqWs54MRZTyuPIgT8wfc9x6wHCkNPqui2y3rdS3CUSrDHLjt9+zk5Ut h4S3kz6Aw7ejSaaAQS7UEyeZhiTioEKMOg36MgfEuIlz5XAbIqGh79DyAnn4HTqFzWyQOr9z5 Fe6PQbk6B1mg2k6QcBS/rYnhlEY+8sKp/rZ1TNQyjbC6wIePpY1Gkgu5ZgbxFAQoQoVHUg7uO 0Ul4RxNjEDSRmDvl6o34auQzLnxvuAjeWrEVGAz2UrWdh3Ud7WPTQEajrYTql3oElV5Mk8rv7 6UUmxyum7kyUyt5Iah+yunU7dddv5xAEtwQE0as/B0GjMUdxaaWyLEw5VUsefeVPskhMCY0Xu uxdkTBGzEcFbN4vf036MhfaArJfG8SVPASE6GmpIpWk+n8xGgHjDzbDQ5hDyTwDAb4O5Unag/ AN6hG0uilWduq0r6lnNZyg6yVzsgEOVR+GgGiJy1En0eakisLHh4W53oMlck1OQ7wofBsn1uf PXlGCrUYQgRRqqIJieRyCZJ/hkhVLG8iSvQKuObPEOD633t4dxtJWQ1+EqjEnC1PboGx3ao5l 5V6TYmC archived-at: Mon, 16 May 2016 12:01:34 -0000 On 16.05.2016 12:46, Alain Stalder wrote: > In order to get a better understanding, I made two configurable changes > in ClassInfo, in a branch from the GROOVY_2_4_6 tag (ClassInfo is still > practically the same in the GROOVY_2_4_X branch): > > - -Dgctest.classreftype=(hard|soft|weak|phantom), where hard=as today, > soft=SoftReference > - -Dgctest.cacheclassvalue=(true|false), if true and using ClassValue, > then do not cache it > > See here: > https://github.com/jexler/groovy/compare/GROOVY_2_4_6...jexler:f92c2866653208ad68db5580b5bf9febc347fe1d > > > Compiled Groovy JAR: > https://www.jexler.net/groovy-2.4.6-gctest.jar [...] > Then I ran a full matrix of tests: > > ------------------------------------------------------------------------ > same loader | use class value | cache class value | hard | soft | weak > ------------------------------------------------------------------------ > YES | YES | YES | FAIL | FAIL | FAIL > YES | YES | NO | FAIL | FAIL | FAIL > YES | NO | -- | OK | OK* | OK* > ------------------------------------------------------------------------ > NO | YES | YES | OK | OK* | OK* > NO | YES | NO | OK | OK* | OK* > NO | NO | -- | FAIL | OK* | OK* > ------------------------------------------------------------------------ > > - "same loader" <=> java [opts] -XX:MaxMetaspaceSize=64m -Xmx512m -cp . > ClassGCTester -cp groovy-2.4.6-gctest.jar:filling/ -parent null -classes > GroovyFilling > - not "same loader" <=> java [opts] -XX:MaxMetaspaceSize=64m -Xmx512m > -cp .:groovy-2.4.6-gctest.jar ClassGCTester -cp filling/ -parent tester > -classes GroovyFilling > - "use class value" <=> -Dgroovy.use.classvalue= > - "cache class value" <=> -Dgctest.cacheclassvalue= > - "hard"|"soft"|"weak" <=> -Dgctest.classreftype= > > * Garbage collection in all cases still only when the limit on Metaspace > or Heap is reached. > > So: > - Caching ClassValue or not made no difference. > - Using weak oder soft references did not help when using ClassValue. > - When not using ClassValue, using weak or soft references helped. :) Even if hard references had been used everywhere, it is only for a single iteration. It means unless data leaks into a more global structure, it must be collectable. So the non-ClassValue version working in this scenario is no sign of correctness for the memory awareness of the used structures at all. > Actually the latter is also reflected (as I noticed in retrospect) by > the pull request by John Wagenleitner for "GROOVY-7683 - Memory leak > when using Groovy as JSR-223 scripting language": > https://github.com/apache/groovy/pull/219/files > > There a WeakReference is used. yes, I think that is something we should do. > Which brings my mind back to my question regarding whether it is "good > architecture" to have a reference to the class in ClassInfo (or any > other metadata associated with a class) - again, I mean fundamentally, > independently of whether this is an option for a Groovy 2.4.7 or even > anything before a Groovy 3, because I fear it would likely require to > change several Groovy APIs and internals. ok, let´s assume the ClassInfo does not reference the class, then as soon as you have a MetaClass, you have a reference to the class again. If not there, then in the method accessors... bye Jochen