Re: Cleaning up threading code

From: Joe Conway <mail(at)joeconway(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cleaning up threading code
Date: 2023-06-10 15:19:46
Message-ID: 7c7209e1-3ecc-877f-07a2-d2e44f1591af@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/10/23 01:26, Andres Freund wrote:
> On 2023-06-10 14:23:52 +1200, Thomas Munro wrote:
>> I'm not talking
>> about other stuff like C11 atomics, memory models, and the
>> thread_local storage class, which are all very good and interesting
>> topics for another day.
>
> Hm. I agree on C11 atomics and memory models, but I don't see a good reason to
> not add support for thread_local?

Perhaps obvious to most/all on this thread, but something that bit me
recently to keep in mind as we contemplate threads.

When a shared object library (e.g. extensions) is loaded, the init()
function, and any functions marked with the constructor attribute, are
executed. However they are not run again during thread_start().

So if there is thread local state that needs to be initialized, the
initialization needs to be manually redone in each thread. Unless there
is some mechanism similar to a constructor that I missed?

--
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-06-10 15:46:00 Re: Do we want a hashset type?
Previous Message Peter Eisentraut 2023-06-10 14:17:27 Re: abi-compliance-checker