Hi,

On Mon, 31 Mar 2025 at 21:15, Melanie Plageman
<melanieplage...@gmail.com> wrote:
>
> On Mon, Mar 31, 2025 at 12:27 PM Nazir Bilal Yavuz <byavu...@gmail.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: v7-0001-Optimize-autoprewarm-with-read-streams.patch
Description: Binary data

Attachment: v7-0002-Count-free-buffers-at-the-start-of-the-autoprewar.patch
Description: Binary data

Reply via email to