Re: Using read stream in autoprewarm
От | Melanie Plageman |
---|---|
Тема | Re: Using read stream in autoprewarm |
Дата | |
Msg-id | CAAKRu_YSkRJnxdd+fUKFRKh1-JXimheq6aVKLzZ-RsCEk0HQaA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Using read stream in autoprewarm (Nazir Bilal Yavuz <byavuz81@gmail.com>) |
Ответы |
Re: Using read stream in autoprewarm
|
Список | pgsql-hackers |
On Tue, Apr 1, 2025 at 8:50 AM Nazir Bilal Yavuz <byavuz81@gmail.com> wrote: > > I am attaching v8, which is an updated version of the v7. I tried to > get rid of these local variables and refactored code to make logic > more straightforward instead of going back and forth. > > 0001 and 0002 are v8. 0003 is another refactoring attempt to make code > more straightforward. I did not squash 0003 to previous patches as you > might not like it. I looked at the code on your github branch that has all three of these squashed together. I think our approaches are converging. I like that you are fast-forwarding to the next filenumber or fork number explicitly when there is a bad relation or fork. I've changed my version (see newest one attached) to do the fast-forwarding inline instead of in a separate function like yours (the function didn't save many LOC and actually may have added to cognitive overhead). Compared to my version, I think you avoided one level of loop nesting with your if (!rel) else if (smgrexists(RelationGetSmgr(rel), blk->forknum)) else but for starters, I don't think you can do this: else if (smgrexists(RelationGetSmgr(rel), blk->forknum)) because you didn't check if you have a legal forknum first And, I actually kind of prefer the explicitly nested structure loop through all relations loop through all forks loop through all buffers While in the old structure, I liked your autoprewarm_prewarm_relation() function, but I think it is nicer inlined like in my version. It makes the loop through all buffers explicit too. I know you mentioned off-list that you don't like the handling of global objects in my version, but I prefer doing it this way (even though we have to check for in the loop condition) to having to set the current database once we reach non-shared objects. It feels too fiddly. This way seems less error prone. Looking at this version, what do you think? Could we do it better? Let me know what you think of this version. I think it is the best of both our approaches. I've separated it into two commits -- the first does all the refactoring without using the read stream API and the second one uses the read stream API. On another topic, what are the minimal places we need to call have_free_buffers() (in this version)? I haven't even started looking at the last patch you've been sending that is about checking the freelist. I'll have to do that next. - Melanie
Вложения
В списке pgsql-hackers по дате отправления: