Re: Creating a DSA area to provide work space for parallel execution - Mailing list pgsql-hackers

From Dilip Kumar
Subject Re: Creating a DSA area to provide work space for parallel execution
Date
Msg-id CAFiTN-sTsZTnc0suy5F9bOTNv2+YcHV33yPZBr0G7e2Qzr=5PQ@mail.gmail.com
Whole thread Raw
In response to Re: Creating a DSA area to provide work space for parallel execution  (Dilip Kumar <dilipbalaut@gmail.com>)
Responses Re: Creating a DSA area to provide work space for parallel execution
List pgsql-hackers
I have one more question,

In V1 we were calling dsa_detach in ExecParallelCleanup and in
ParallelQueryMain, but it's removed in v2.

Any specific reason ?
Does this need to be used differently ?
ExecParallelCleanup(ParallelExecutorInfo *pei){
+ if (pei->area != NULL)
+ {
+ dsa_detach(pei->area);
+ pei->area = NULL;
+ }

After this changes, I am getting DSM segment leak warning.

I am calling dsa_allocate and dsa_free.

On Thu, Nov 24, 2016 at 8:09 PM, Dilip Kumar <dilipbalaut@gmail.com> wrote:
> On Wed, Nov 23, 2016 at 5:42 PM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> ... or we could allow DSA areas to be constructed inside existing
>> shmem, as in the attached patch which requires dsa_create_in_place,
>> from the patch at
>> https://www.postgresql.org/message-id/CAEepm%3D0-pbokaQdCXhtYn%3Dw64MmdJz4hYW7qcSU235ar276x7w%40mail.gmail.com
>> .
> Seems like there is problem in this patch..
>
> In below code,  pei->area is not yet allocated at this point , so
> estate->es_query_area will always me NULL ?
>
> + estate->es_query_area = pei->area;
> +
>   /* Create a parallel context. */
>   pcxt = CreateParallelContext(ParallelQueryMain, nworkers);
>   pei->pcxt = pcxt;
> @@ -413,6 +423,10 @@ ExecInitParallelPlan(PlanState *planstate, EState
> *estate, int nworkers)
>   shm_toc_estimate_keys(&pcxt->estimator, 1);
>   }
>
> + /* Estimate space for DSA area. */
> + shm_toc_estimate_chunk(&pcxt->estimator, PARALLEL_AREA_SIZE);
> + shm_toc_estimate_keys(&pcxt->estimator, 1);
> +
>   /* Everyone's had a chance to ask for space, so now create the DSM. */
>   InitializeParallelDSM(pcxt);
>
> @@ -466,6 +480,14 @@ ExecInitParallelPlan(PlanState *planstate, EState
> *estate, int nworkers)
>   pei->instrumentation = instrumentation;
>   }
>
> + /* Create a DSA area that can be used by the leader and all workers. */
> + area_space = shm_toc_allocate(pcxt->toc, PARALLEL_AREA_SIZE);
> + shm_toc_insert(pcxt->toc, PARALLEL_KEY_AREA, area_space);
> + pei->area = dsa_create_in_place(area_space, PARALLEL_AREA_SIZE,
> + LWTRANCHE_PARALLEL_EXEC_AREA,
> +   "parallel query memory area");
>
>
> --
> Regards,
> Dilip Kumar
> EnterpriseDB: http://www.enterprisedb.com



-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: Creating a DSA area to provide work space for parallel execution
Next
From: Greg Stark
Date:
Subject: Re: UNDO and in-place update