Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZ2nd-0005BB-93 for pgsql-jdbc@arkaria.postgresql.org; Wed, 23 Oct 2013 18:04:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VZ2nc-00077f-Hp for pgsql-jdbc@arkaria.postgresql.org; Wed, 23 Oct 2013 18:04:52 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZ2nb-00076J-9y for pgsql-jdbc@postgresql.org; Wed, 23 Oct 2013 18:04:51 +0000 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZ2nU-00065P-Fl for pgsql-jdbc@postgresql.org; Wed, 23 Oct 2013 18:04:50 +0000 Received: by mail-pb0-f52.google.com with SMTP id wy17so1307512pbc.39 for ; Wed, 23 Oct 2013 11:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oPw7f2uy8AQoqr3Mwq+9qn8NITAbABiMiqdLbEAe0hg=; b=TXEjr/SiaXGbm0ra6rL5IwTSmdKAS4CaiOk5NSDe+CFdETxCFiygVz12Drc+jdRxlE qRPb2hqtuk/qgwsEcBmnRLlPB9BuztE8Z0oDl7nEGE3GYEAbEZkpAirrhK+wivn5C9gf OfgFTo65vXhF+Iv+rfYO+mnco/TIpzQDwWGkUSwaeABoDV2QaWHES9Ibbqmzgsoo2nAp HTxzAbDZ5MVg3BHtHohta3BRqDyZe840Lu5f+SLdrsSzZYindZNexebDgDmmdQ+oafBF ntHEy3z1KKRzRgQ+bdppZjW1cIguRbtMzm+hiIKBPJVT3CLD4QX2vSF/RnTdx+WCLicQ x0JA== X-Received: by 10.68.225.9 with SMTP id rg9mr2968660pbc.122.1382551482609; Wed, 23 Oct 2013 11:04:42 -0700 (PDT) Received: from [172.20.12.26] (75-149-43-193-SFBA.hfc.comcastbusiness.net. [75.149.43.193]) by mx.google.com with ESMTPSA id bp5sm353795pbb.18.2013.10.23.11.04.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 11:04:40 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Remove usage of finalizers ? From: Steven Schlansker In-Reply-To: <283F612E-688B-4342-A924-EF67EF86A20A@gmail.com> Date: Wed, 23 Oct 2013 11:04:39 -0700 Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <30D0DB98-4224-425A-B99B-C4BF5CBC30AB@gmail.com> References: <9E5438C0-0A2E-4543-BE06-1E7A6D0E3B83@pilhuhn.de> <4EFCA605-80FE-4D6F-90CE-C124984C95AB@pilhuhn.de> <52677946.4090907@hogranch.com> <283F612E-688B-4342-A924-EF67EF86A20A@gmail.com> To: Adib Saikali X-Mailer: Apple Mail (2.1510) X-Pg-Spam-Score: -0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On Oct 23, 2013, at 10:58 AM, Adib Saikali wrote: > Seems to me that PhantomReferences can solve this problem as they will pr= ovide the ability to the cleanup without causing the performance issues wit= h the finalizers. I am not familiar with the postgres jdbc driver code base= so I have no idea how much work is involved in switching from finalizers t= o phantom references.=20 >=20 > Can anyone with knowledge of the jdbc code base comment on the practicali= ty of moving from finalizers to phantom reference. >=20 Do we in fact know that phantom (or weak?) references are cheaper than Fina= lizers? It may be that switching to References makes turning a "debug mode" on or o= ff much easier (i.e. no need to subclass) but it would be nice to have some= evidence as to whether it will be faster or not, and under what workloads. > On 2013-10-23, at 1:47 PM, Steven Schlansker = wrote: >=20 >>=20 >> On Oct 23, 2013, at 12:22 AM, John R Pierce wrote: >>=20 >>> On 10/23/2013 12:06 AM, Vitalii Tymchyshyn wrote: >>>> I am not big fan of finalizes. But you propose to remove mechanism tha= t works most times, without introducing anything else. >>>> You are saying that as in my incorrect application (and I am 95% sure = you've got incorrect application if you are getting finalizing objects pile= d up) it does not work, let's remove it altogether and make driver also wro= ng. >>>=20 >>> as an outsider to this stuff, with only a superficial understanding of = these finalizers, it seems to me they should log a warning if anything leak= s to them. you don't get rid of them entirely, they provide backup sweepin= g up of neglected debris.. >>>=20 >>=20 >> The specific problem with this is that the mere presence of a non-empty = finalizer increases the cost of object allocation and deallocation by order= s of magnitude (as is claimed by many Java performance resources). All cor= rect applications pretty much have to deallocate these objects explicitly, = as the GC can leave the resources lying around for unbounded time. So havi= ng these finalizers penalizes the correct applications (which I have not ob= served in practice, but OP seemingly has) by some amount. >>=20 >>=20 >> Maybe the best thing would be for the OP to distill the problem down int= o a self-contained code example so we can verify that there aren't any othe= r errors that might be contributing to this problem? It seems that if the = problem was really that big, someone else would have run across it. >>=20 >> Best, >> Steven >>=20 >>=20 >>=20 >> --=20 >> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-jdbc >=20 >=20 >=20 > --=20 > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc