Re: Separate memory contexts for relcache and catcache

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Cc: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, andres(at)anarazel(dot)de, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Separate memory contexts for relcache and catcache
Date: 2024-11-26 13:18:38
Message-ID: CAExHW5vLRUk+9ZxF4FgaqdfmU2e8JbWES7ijhA0Bd6_bekr=Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 26, 2024 at 4:10 PM Rahila Syed <rahilasyed90(at)gmail(dot)com> wrote:

>
>
> Having reviewed the discussion regarding potential fragmentation issues
> caused by
> creating a large number of new contexts in each backend, I would like to
> take a step
> back and better understand the motivation behind separating these contexts.
>
> IIUC, segregating cache memory allocations into RelCacheContext and
> CatCacheContext
> allows for grouping a large number of memory allocations under a
> common context, which, in turn, aids in monitoring memory consumption.
> However,
> I believe this reasoning does not apply to SPICacheContext and
> PlanCacheContext,
> as these contexts do not have any allocations of their own.
>
> How, then, does separating these contexts from CacheMemoryContext improve
> monitoring?
>

A query which accumulates statistics based on the (context) path prefix
(path of PlanCacheContext or SPICacheContext) can be used to provide total
memory allocated for plans. This will work even if we change the names of
child context e.g. CachedPlanContext, CachedQueryContext or if we add more
child contexts. Probably such a change is mostly unlikely. Whether that
advantage is worth spending extra memory in fragmentation? Probably not.
But I just wanted to note some use.

--
Best Wishes,
Ashutosh Bapat

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2024-11-26 13:20:31 Re: Potential Issue with Redundant Restriction Clauses in get_parameterized_baserel_size for PARTITIONED_REL
Previous Message Andrey M. Borodin 2024-11-26 13:14:05 Re: UUID v7