Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4738811A0C for ; Fri, 6 Jun 2014 14:01:21 +0000 (UTC) Received: (qmail 82915 invoked by uid 500); 6 Jun 2014 14:01:20 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 82872 invoked by uid 500); 6 Jun 2014 14:01:20 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 82862 invoked by uid 99); 6 Jun 2014 14:01:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2014 14:01:20 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of prvs=1234a63865=rhs@alum.mit.edu designates 18.7.68.18 as permitted sender) Received: from [18.7.68.18] (HELO alum-mailsec-scanner-6.mit.edu) (18.7.68.18) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2014 14:01:15 +0000 X-AuditID: 12074412-f79ba6d000000bc2-9a-5391c996fdca Received: from outgoing-alum.mit.edu (OUTGOING-ALUM.MIT.EDU [18.7.68.33]) by alum-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id F1.82.03010.699C1935; Fri, 6 Jun 2014 10:00:54 -0400 (EDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) (authenticated bits=0) (User authenticated as rhs@ALUM.MIT.EDU) by outgoing-alum.mit.edu (8.13.8/8.12.4) with ESMTP id s56E0r9I012102 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 6 Jun 2014 10:00:54 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so2520808pbb.19 for ; Fri, 06 Jun 2014 07:00:53 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.68.170.66 with SMTP id ak2mr7022040pbc.5.1402063253419; Fri, 06 Jun 2014 07:00:53 -0700 (PDT) Received: by 10.70.130.101 with HTTP; Fri, 6 Jun 2014 07:00:53 -0700 (PDT) In-Reply-To: References: Date: Fri, 6 Jun 2014 10:00:53 -0400 Message-ID: Subject: Re: High memory footprint of proton-j in ActiveMQ From: Rafael Schloming To: "users@qpid.apache.org" Content-Type: multipart/alternative; boundary=047d7b86d55c2c3d7804fb2b4a00 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsUixO6iqDvt5MRgg8+bDSzOrvjP6MDoMfXO A7YAxihum6TEkrLgzPQ8fbsE7oz1bbuZCxarVyx8VtbAuEahi5GTQ0LARGJhywkWCFtM4sK9 9WxdjFwcQgKXGSX6tp1ignDuMEnM7T/IDOFMYJTYt6uTFaSFV0BQ4uTMJ1DthRJbf11nB7GF BLwktn/8ABbnFAiUWPvrOCNEPEDi+qFVTCA2i4CKxJ09bSwQcwIkunsvgtnCAlYSUyftALPZ BDQltl3eyAZiiwgYS7Qufg22lxlo/rcbH1gmMArMQnLGLCSpWYwcQLa6xPp5QhBhNYnb266y Q9jaEssWvmZewMi6ilEuMac0Vzc3MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyMkjIV2MK4/ KXeIUYCDUYmHN6B/QrAQa2JZcWXuIUZJDiYlUV7d3RODhfiS8lMqMxKLM+KLSnNSiw8xSnAw K4nwsjUD5XhTEiurUovyYVLSHCxK4rw/F6v7CQmkJ5akZqemFqQWwWRlODiUJHhXnABqFCxK TU+tSMvMKUFIM3FwggznkhIpTs1LSS1KLC3JiAdFdnwxMLZBUjxAe4+BtPMWFyTmAkUhWk8x GnPM+3+0jYnj16LTbUxCLHn5ealS4rz/jgOVCoCUZpTmwS2CJbBXjOJAfwvzLgIZyANMfnDz XgGtYgJa9SsTbFVJIkJKqoEx9TzT1XdJt7cc9ktMvHd7xZKtG5Xdb3tLMZ4sDtIsVXt0PeyU 3P0NU5Q330tb/vvO20mSLPzr81Rk16vr3Ym6fvih1sU1i/h1PpikxXkl3f4zr+68wXr7HTty LxtPn/pAoOxwt/EjvcCuG7wMM958yNwcFXuTOTf1ToOmhpHw8ufGTF8mr9WPUmIpzkg01GIu Kk4EAJr2wC87AwAA X-Virus-Checked: Checked by ClamAV on apache.org --047d7b86d55c2c3d7804fb2b4a00 Content-Type: text/plain; charset=UTF-8 That sounds like a worthy improvement to me. We could possibly put in a threshold to let people choose their own tradeoff, e.g. below X buffer size we use one strategy, and above it we use another. Either way, I'd go ahead and file a JIRA with a pointer to your commit. --Rafael On Thu, Jun 5, 2014 at 4:48 PM, Marcel Meulemans < m.meulemans@tkhinnovations.com> wrote: > I have been experiencing high (resident) memory usage when using ActiveMQ > with large amounts of AMQP connections. > > After some investigation I have traced this memory usage back to proton-j. > The cause is that by default ActiveMQ defines a maxFrameSize of 1MB for the > AmqpWireFormat and in proton-j there are two classes (TrasportOutputAdaptor > and FrameParser) that hold a ByteBuffer of maxFrameSize throughout their > lifetime. In the case of the 1MB frame size that means that each transport > has a fairly high memory footprint (2MB) considering that this memory is > hardly ever used, i.e. only when there is a frame to transfer in/out and in > most cases the frame will not be maxFrameSize. Because there is a Transport > for every connection the memory usage can become quite high when dealing > with many connections with large maxFrameSize, e.g. 2GB for only 1000 > connections (I was aiming for 10000 connections so you see my problem). > > Generally the buffer allocation may not be a problem but in my case they > are so I decided to modify proton so that it does not require these buffers > to exist at all times. The change I made are a classical tradeoff between > memory usage and cpu cycles. The memory usage has been reduced and the cpu > usage increased (more frequent allocations). The buffers are only allocated > when needed and are released as soon as they hold no more data. The changes > (which pass all tests and have the desired results) can be found here: > https://github.com/marcelmeulemans/qpid-proton > > Because this may not be considered a bug or even an improvement I am > sharing it here so you guys can decide is this is in anyway useful. > > -- > Marcel > --047d7b86d55c2c3d7804fb2b4a00--