Re: aio: worker: Free SMGR objects when idle - Mailing list pgsql-hackers

From Nazir Bilal Yavuz
Subject Re: aio: worker: Free SMGR objects when idle
Date
Msg-id CAN55FZ2JTHmB+xRQQd8LPE0vO0c=95yP8BHHJmZBe93M1u_SLA@mail.gmail.com
Whole thread
In response to Re: aio: worker: Free SMGR objects when idle  (shihao zhong <zhong950419@gmail.com>)
Responses Re: aio: worker: Free SMGR objects when idle
List pgsql-hackers
Hi,

Thank you for looking into this all!

On Tue, 22 Sept 2026 at 03:12, shihao zhong <zhong950419@gmail.com> wrote:
>
> Right, the per IO check puts the spinlock in the hot path.
>
> The barrier also only releases, it does not destroy, so it does not
> fix what Nazir reported. The hash table in the IO worker keeps
> growing either way. Nothing pins those entries in an IO worker, and
> smgrdestroyall only zaps unpinned ones, so destroying them there
> should be safe.

Correct.


> That suggests a version with no lock at all. Keep the cleanup where
> Nazir put it, at a safe point in the worker loop, but trigger it on a
> local condition, the number of unpinned entries being over a cap,
> rather than on a checkpoint generation. No shared state, and it also
> covers a worker that never goes idle.

We need to make a function call to hash_get_num_entries() for each IO
to check number of unpinned entries, which doesn't sound good to me.
This is especially true for the partitioned case.

For now, I used the number of IOs (capped at 1024) since the last smgr
cleanup. This solution removes CheckpointerShmem->ckpt_lck contention
and worker goes idle problem.

-- 
Regards,
Nazir Bilal Yavuz
Microsoft

Attachment

pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: [PATCH] Add ALTER SYSTEM RELOAD
Next
From: shihao zhong
Date:
Subject: Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten