| From: | Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: aio: worker: Free SMGR objects when idle |
| Date: | 2026-09-24 10:36:37 |
| Message-ID: | CAN55FZ24H5YjaZYayTp7xag7-JH=2qQ4CJQvFf4tTD4mAeD9Ew@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Wed, 23 Sept 2026 at 15:18, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> On the entry count. Nothing is pinned in an IO worker, only the
> relcache calls smgrpin(), which also answers Alexandre's question. So
> the unpinned count is just hash_get_num_entries(), and that only reads
> a counter. SMgrRelationHash is local and not partitioned. The IO
> counter is fine with me too though.
You are right that SMgrRelationHash is local and not partitioned, I
missed that. Then, I think using the 'number of unpinned entries'
makes more sense because the IO count won't work well when multiple
IOs use the same relation. I introduced the smgrnumentries() function
in v3 to get the number of cached SMgrRelation objects.
> One gap in v2. v1 cleaned up when the worker went idle, v2 does not.
> A worker that does fewer than 1024 IOs and then sleeps keeps those
> entries and their descriptors until it gets busy again. #19622 has
> that case, workers idle for 51 minutes still holding descriptors of
> dropped tables. Maybe also clean up in the idle branch when
> ios_since_smgr_cleanup > 0. That needs no lock either.
Done.
One thing remains: if the cache doesn't grow enough and the worker
doesn't go idle (i.e. all IOs process less than
PGAIO_WORKER_SMGR_CLEANUP_THRESHOLD relation), we don't clear the SMGR
objects but I think this is a correct behavior.
--
Regards,
Nazir Bilal Yavuz
Microsoft
| Attachment | Content-Type | Size |
|---|---|---|
| v3-0001-aio-worker-Bound-SMGR-cache-growth.patch | text/x-patch | 4.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-09-24 10:36:41 | Re: PG19: two RI fast-path issues found while testing the batching revert |
| Previous Message | Amit Langote | 2026-09-24 10:28:07 | Re: potentially missed pgindent in REL_19_STABLE |