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 B7710200AE2 for ; Fri, 13 May 2016 02:22:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B5CD8160A10; Fri, 13 May 2016 00:22:15 +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 08293160939 for ; Fri, 13 May 2016 02:22:14 +0200 (CEST) Received: (qmail 97136 invoked by uid 500); 13 May 2016 00:22:14 -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 97123 invoked by uid 99); 13 May 2016 00:22:13 -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; Fri, 13 May 2016 00:22:13 +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 6AC18C1F91 for ; Fri, 13 May 2016 00:22:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.28 X-Spam-Level: X-Spam-Status: No, score=0.28 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from mx1-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 WB-L5ud51uA4 for ; Fri, 13 May 2016 00:22:11 +0000 (UTC) Received: from exsmtp13.agrinet.ch (exsmtp13.agrinet.ch [81.221.254.206]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id B56F05F23C for ; Fri, 13 May 2016 00:22:10 +0000 (UTC) Received: from [192.168.1.2] ([194.191.233.117]) by imp01.agrinet.ch with id tcN41s0052YeanW03cN4zd; Fri, 13 May 2016 02:22:04 +0200 X-IMP-FROM: _________ X-IMP-AUTH_USERNAME: X-Original-IP: 194.191.233.117 To: dev@groovy.apache.org From: Alain Stalder Subject: Improve Groovy class loading performance and memory management Message-ID: <57351E2A.2070304@span.ch> Date: Fri, 13 May 2016 02:22:02 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Fri, 13 May 2016 00:22:15 -0000 Hi everybody I had considered to submit a major feature request for Groovy with the text further below, because it appears to me that there might possibly be considerable room for improvement, but since I am not developing Groovy myself I thought that maybe I would just present it here and if people think such a feature request (or a somewhat similar one) would still make sense, it could still be created (by me or someone else)... --- Improve Groovy class loading performance and memory management Consider the maybe most typical use case of Groovy as a dynamic language: Within a Java VM, Groovy scripts are dynamically compiled, be it explicitly by using a GroovyShell or a GroovyClassLoader, or more implictly e.g. with a ConfigSlurper. Qualitatively this often has the following result in the Java VM: Metaspace resp. PermGen, and Heap in parallel, just grow until a configured limit is reached (and note that there is none by default for Metaspace in Java 8 and later), often only then is it garbage collected. With Java classes, at least with simple ones, this looks often different, those appear to be garbage collected much more quickly. Another qualitative difference is that loading a Groovy class and instantiating it seems typically to be considerably slower than instantiating a Java class with similar functionality, even quite drastically so, more than one would expect even considering the need to create metadata for dynamic function calls etc. At least that has been my experience over the past few years. Seen from very far ("management", "marketing", "sales"), this not optimal for a dynamic language, getting these two things right - memory management and class loading performace - is arguably "core business". Obviously Groovy classes are more complex than most Java classes and there is existing code and limitations of Java VMs and probably more issues... But in the medium term, I think and feel that it would be good to find out what really impedes better performance and a more regular garbage collection. Possibly the problems are really hard and complex, but some might also be easy, and maybe some would become quite easy after some simple changes in the Java VM, but before such changes can be requested, it has to be analyzed what these could or should be. Attached is a simple command line Java test program, ClassGCTester.java, that can be used to make some very basic measurements of class loading memory behavior and performance. The source code and a readme with two examples (one for Java and one for Groovy) is also at https://github.com/jexler/classgc, and I think it might help to illustrate current limitations and maybe also a little bit initially with analysis. --- Note the tool at https://github.com/jexler/classgc and the readme with two illustrative examples - one Java class, one Groovy class - there... Alain