Re: [HACKERS] Parallel bitmap heap scan - Mailing list pgsql-hackers
From | Dilip Kumar |
---|---|
Subject | Re: [HACKERS] Parallel bitmap heap scan |
Date | |
Msg-id | CAFiTN-umYWwR10PCep6sb=B4NX42nPFYdRimn-VbJKDiHPryNw@mail.gmail.com Whole thread Raw |
In response to | Re: [HACKERS] Parallel bitmap heap scan (Haribabu Kommi <kommi.haribabu@gmail.com>) |
Responses |
Re: [HACKERS] Parallel bitmap heap scan
|
List | pgsql-hackers |
On Tue, Jan 31, 2017 at 7:47 AM, Haribabu Kommi <kommi.haribabu@gmail.com> wrote: > Thanks for the update. I have some comments > Thanks for the review. > > 0002-hash-support-alloc-free-v14.patch: > > > + if (tb->alloc) > + { > > The memory for tb->alloc is allocated always, is the if check still > required? In parallel case, only first worker will call SH_CREATE, other worker will only do palloc for pagetable and copy the reference from main worker, so they will not have allocator. > 0003-parallel-bitmap-heap-scan-v14.patch: > > > + * and set parallel flag in lower level bitmap index scan. Later > + * bitmap index node will use this flag to indicate tidbitmap that > + * it needs to create an shared page table. > + */ > > I feel better to mention, where this flag is used, so that it will be more > clear. Done > > > + * Mark tidbitmap as shared and also store DSA area in it. > + * marking tidbitmap as shared is indication that this tidbitmap > + * should be created in shared memory. DSA area will be used for > > The flag of shared is set in tidbitmap structure itself, but the > comment is mentioned that tidbitmpa should be created in shared memory. > I think that is the page table that needs to be created in shared memory. > Providing some more information here will be helpful. > Done > > - node->tbmres = tbmres = tbm_iterate(tbmiterator); > + node->tbmres = tbmres = pbms_parallel_iterate(tbmiterator, > + pbminfo ? &pbminfo->tbmiterator : NULL); > > Instead Passing both normal and paralle iterators to the functions > and checking inside again for NULL, How about just adding check > in the caller itself? Or if you prefer the current method, then try to > explain the details of input in the function header and more description. > Done as you said. > > + /* Increase prefetch target if it's not yet at the max. */ > + if (node->prefetch_target < node->prefetch_maximum) > > I didn't evaluate all scenarios, but the above code may have a problem, > In case of parallel mode the the prefetch_target is fetched from node > and not from the pbminfo. Later it gets from the pminfo and update that. > May be this code needs to rewrite. > Fixed it. > > + TBMIterator *iterator = node->prefetch_iterator; > > Why another variable? Why can't we use the prefetch_iterator itself? > Currently node->tbmiterator and node->prefetch_iterator are initialized > irrespective of whether is it a parallel one or not. But while using, there > is a check to use the parallel one in case of parallel. if it is the case, > why can't we avoid the initialization itself? Fixed > > > + else > + needWait = false; > > By default needWait is false. Just set that to true only for the > case of PBM_INPROGRESS > Actually inside the while loop, suppose first we set needWait = true, if PBM_INPROGRESS and got for ConditionalSleep, After it come out of sleep, we need to check that PBM_FINISHED is set or we need to sleep again, So in such case we need to reset it to needWait=false. However this can be done by directly returning if it's PBM_FINISHED. But I want to keep below the logic common. + SpinLockRelease(&pbminfo->state_mutex); + + /* If we are leader or leader has already created a TIDBITMAP */ + if (leader || !needWait) + break; > + * so that during free we can directly get the dsa_pointe and free it. > > dsa_pointe -> dsa_pointer Done > > > +typedef struct > +{ > + TIDBitmap *tbm; /* TIDBitmap we're iterating over */ > + int spageptr; /* next spages index */ > + int schunkptr; /* next schunks index */ > + int schunkbit; /* next bit to check in current schunk */ > + TBMIterateResult output; /* MUST BE LAST (because variable-size) */ > +} TBMIterator; > > I didn't find the need of moving this structure. Can you point me where it > is used. Because pbms_parallel_iterate need to access this structure so I moved it to tidbitmap.h -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Attachment
pgsql-hackers by date: