Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 20DA09C9C for ; Thu, 16 May 2013 14:14:41 +0000 (UTC) Received: (qmail 92453 invoked by uid 500); 16 May 2013 14:14:41 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 92334 invoked by uid 500); 16 May 2013 14:14:39 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 92176 invoked by uid 99); 16 May 2013 14:14:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 May 2013 14:14:34 +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 mar09086@adobe.com designates 64.18.1.242 as permitted sender) Received: from [64.18.1.242] (HELO exprod6og124.obsmtp.com) (64.18.1.242) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 May 2013 14:14:27 +0000 Received: from outbound-smtp-1.corp.adobe.com ([192.150.11.134]) by exprod6ob124.postini.com ([64.18.5.12]) with SMTP ID DSNKUZTprjWbz3sjWXp6+56SgcbI/38TMJdt@postini.com; Thu, 16 May 2013 07:14:07 PDT Received: from inner-relay-4.eur.adobe.com (inner-relay-4.adobe.com [193.104.215.14]) by outbound-smtp-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id r4GEAoKs000696 for ; Thu, 16 May 2013 07:10:51 -0700 (PDT) Received: from nacas01.corp.adobe.com (nacas01.corp.adobe.com [10.8.189.99]) by inner-relay-4.eur.adobe.com (8.12.10/8.12.9) with ESMTP id r4GEBPH1014234 for ; Thu, 16 May 2013 07:14:04 -0700 (PDT) Received: from eurcas01.eur.adobe.com (10.128.4.27) by nacas01.corp.adobe.com (10.8.189.99) with Microsoft SMTP Server (TLS) id 8.3.298.1; Thu, 16 May 2013 07:13:44 -0700 Received: from eurmbx02.eur.adobe.com ([10.128.4.126]) by eurcas01.eur.adobe.com ([10.128.4.27]) with mapi; Thu, 16 May 2013 15:13:43 +0100 From: Lukas Eder To: "oak-dev@jackrabbit.apache.org" Date: Thu, 16 May 2013 15:13:41 +0100 Subject: MongoMK Revision.toString() usage Thread-Topic: MongoMK Revision.toString() usage Thread-Index: Ac5SP5H6Kx97vSkrSF+WMHQF96zGgg== Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.3.2.130206 acceptlanguage: de-DE, en-US Content-Type: multipart/alternative; boundary="_000_CDBAB63512F6lukasederadobecom_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_CDBAB63512F6lukasederadobecom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, I've been investigating Oak performance and found a couple of cases where M= ongoMK makes use of stringified versions of the org.apache.jackrabbit.mongo= mk.Revision type. One example of such a problem was reported here [1]. I have a couple of things that I'd like to talk about, concerning Revision.= toString() usage: 1. toString() should hardly ever be used for anything other than debuggin= g. It is very hard to find relevant matching references of Object.toString(= ) in a Java code base. In other words, toString() is almost not "refactorab= le". E.g. is hard to predict what side-effects a change to the toString() b= ehaviour will have. Ideally, toString() should delegate to another method, = such as format(), where the predicable logic is really implemented. 2. Revision has a much lower memory footprint than its string representat= ion, so it is actually be better suited to be used in maps, caches, etc. 3. MongoMK.isCommitted() is an example that shows how revisions are unnec= essarily transformed back and forth to strings. In a larger profiling session, Revision.fromString() and Revision.toString(= ) accounted for a total of around 1.5% of all CPU time on my machine. This may seem like micro-optimisation to some, but I think that we should t= ake these things seriously, as they might add up to a significant amount of= CPU and memory waste, if practiced across a large code base. Please, let me know what you think. Cheers Lukas [1]: https://issues.apache.org/jira/browse/OAK-825 --_000_CDBAB63512F6lukasederadobecom_--