From: Steven Schlansker <stevenschlansker@gmail.com>
To: Adib Saikali <adib.saikali@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Remove usage of finalizers ?
Date: Wed, 23 Oct 2013 11:04:39 -0700
Message-ID: <30D0DB98-4224-425A-B99B-C4BF5CBC30AB@gmail.com> (raw)
In-Reply-To: <283F612E-688B-4342-A924-EF67EF86A20A@gmail.com>
References: <9E5438C0-0A2E-4543-BE06-1E7A6D0E3B83@pilhuhn.de>
<CABWW-d2rT-dGEh-hrtemgo2z6dm5H2VUz86y-xmgs3p_6Hv+_w@mail.gmail.com>
<E177372F-3F90-4F1D-9A34-84B3A678A988@pilhuhn.de>
<CABWW-d2EfWuCV7ZDGoWpz1GiFEM_zNX6rq1PHdHNm_HbZ3EM2w@mail.gmail.com>
<B86EB807-F8DF-4F2A-BBC9-6CAB925FCDE9@pilhuhn.de>
<CADK3HH+CaUF3gG-D3fTZn4OeKdP+39=iqgww1Wp7hYBiypKidg@mail.gmail.com>
<CAPPfruy+mPWfg9WmWQGaRVTAQS9kBgF1pi9oJB4ZcgRyZ87few@mail.gmail.com>
<CABWW-d1iMgM9-fs2uJ2Vk5rTQnN29nvUvfhQUg0k=jxao-T_KA@mail.gmail.com>
<4EFCA605-80FE-4D6F-90CE-C124984C95AB@pilhuhn.de>
<CABWW-d0A73dsyfu44gJ5o2K1bHHxAUXWWsrCGTnj779QamK1gA@mail.gmail.com>
<52677946.4090907@hogranch.com>
<C4280E84-5DC2-47E1-B87B-F2A7E681EB3D@gmail.com>
<283F612E-688B-4342-A924-EF67EF86A20A@gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
On Oct 23, 2013, at 10:58 AM, Adib Saikali <adib.saikali@gmail.com> wrote:
> Seems to me that PhantomReferences can solve this problem as they will provide the ability to the cleanup without causing the performance issues with 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 to phantom references.
>
> Can anyone with knowledge of the jdbc code base comment on the practicality of moving from finalizers to phantom reference.
>
Do we in fact know that phantom (or weak?) references are cheaper than Finalizers?
It may be that switching to References makes turning a "debug mode" on or off 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 <stevenschlansker@gmail.com> wrote:
>
>>
>> On Oct 23, 2013, at 12:22 AM, John R Pierce <pierce@hogranch.com> wrote:
>>
>>> On 10/23/2013 12:06 AM, Vitalii Tymchyshyn wrote:
>>>> I am not big fan of finalizes. But you propose to remove mechanism that 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 piled up) it does not work, let's remove it altogether and make driver also wrong.
>>>
>>> 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 leaks to them. you don't get rid of them entirely, they provide backup sweeping up of neglected debris..
>>>
>>
>> The specific problem with this is that the mere presence of a non-empty finalizer increases the cost of object allocation and deallocation by orders of magnitude (as is claimed by many Java performance resources). All correct applications pretty much have to deallocate these objects explicitly, as the GC can leave the resources lying around for unbounded time. So having these finalizers penalizes the correct applications (which I have not observed in practice, but OP seemingly has) by some amount.
>>
>>
>> Maybe the best thing would be for the OP to distill the problem down into a self-contained code example so we can verify that there aren't any other 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.
>>
>> Best,
>> Steven
>>
>>
>>
>> --
>> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: stevenschlansker@gmail.com, adib.saikali@gmail.com
Subject: Re: Remove usage of finalizers ?
In-Reply-To: <30D0DB98-4224-425A-B99B-C4BF5CBC30AB@gmail.com>
References: <9E5438C0-0A2E-4543-BE06-1E7A6D0E3B83@pilhuhn.de> <CABWW-d2rT-dGEh-hrtemgo2z6dm5H2VUz86y-xmgs3p_6Hv+_w@mail.gmail.com> <E177372F-3F90-4F1D-9A34-84B3A678A988@pilhuhn.de> <CABWW-d2EfWuCV7ZDGoWpz1GiFEM_zNX6rq1PHdHNm_HbZ3EM2w@mail.gmail.com> <B86EB807-F8DF-4F2A-BBC9-6CAB925FCDE9@pilhuhn.de> <CADK3HH+CaUF3gG-D3fTZn4OeKdP+39=iqgww1Wp7hYBiypKidg@mail.gmail.com> <CAPPfruy+mPWfg9WmWQGaRVTAQS9kBgF1pi9oJB4ZcgRyZ87few@mail.gmail.com> <CABWW-d1iMgM9-fs2uJ2Vk5rTQnN29nvUvfhQUg0k=jxao-T_KA@mail.gmail.com> <4EFCA605-80FE-4D6F-90CE-C124984C95AB@pilhuhn.de> <CABWW-d0A73dsyfu44gJ5o2K1bHHxAUXWWsrCGTnj779QamK1gA@mail.gmail.com> <52677946.4090907@hogranch.com> <C4280E84-5DC2-47E1-B87B-F2A7E681EB3D@gmail.com> <283F612E-688B-4342-A924-EF67EF86A20A@gmail.com> <30D0DB98-4224-425A-B99B-C4BF5CBC30AB@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox