| From: | Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> | 
|---|---|
| To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> | 
| Cc: | Kirill Reshke <reshkekirill(at)gmail(dot)com>, Matheus Alcantara <mths(dot)dev(at)pm(dot)me>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: Using read stream in autoprewarm | 
| Date: | 2025-03-31 18:58:30 | 
| Message-ID: | CAN55FZ3mpTL5GXpVVq=ZjaVVxRzFehyPhDsRz0Cn-ARz0vhxwA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hi,
On Mon, 31 Mar 2025 at 21:15, Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
>
> On Mon, Mar 31, 2025 at 12:27 PM Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> wrote:
> >
> > I worked on an alternative approach, I refactored code a bit. It does
> > not traverse the list two times and I think the code is more suitable
> > to use read streams now. I simply get how many blocks are processed by
> > read streams and move the list forward by this number, so the actual
> > loop skips these blocks. This approach is attached with 'alternative'
> > prefix.
>
> I am leaning toward the refactored approach because I don't think we
> want to go through the array twice and I think it is hard to get it
> right with incrementing p.pos in both places and being sure we
> correctly close the relation etc.
I liked it more as well.
> Looking at your alternative approach, I don't see how the innermost
> while loop in autoprewarm_database_main() is correct
>
>         /* Check whether blocknum is valid and within fork file size. */
>         while (cur_filenumber == blk->filenumber &&
>                blk->blocknum >= nblocks_in_fork)
>         {
>             /* Move to next forknum. */
>             pos++;
>             continue;
>         }
>
> Won't this just infinitely loop?
Oops, you are right. It should be an if statement instead of a while
loop, fixed now. Also, moved 'dsm_detach(seg);' to its previous place
to reduce diff. Attached as v7. Do you think that I should continue to
attach both approaches?
-- 
Regards,
Nazir Bilal Yavuz
Microsoft
| Attachment | Content-Type | Size | 
|---|---|---|
| v7-0001-Optimize-autoprewarm-with-read-streams.patch | application/octet-stream | 7.7 KB | 
| v7-0002-Count-free-buffers-at-the-start-of-the-autoprewar.patch | application/octet-stream | 3.2 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2025-03-31 19:09:24 | Re: explain analyze rows=%.0f | 
| Previous Message | Masahiko Sawada | 2025-03-31 18:51:30 | Re: Make COPY format extendable: Extract COPY TO format implementations |