Re: [PoC] Improve dead tuple storage for lazy vacuum - Mailing list pgsql-hackers
From | John Naylor |
---|---|
Subject | Re: [PoC] Improve dead tuple storage for lazy vacuum |
Date | |
Msg-id | CANWCAZar3Sz4QtD5V=inEG9hgS891ctr=Npc7u=uPFMkHyq=pw@mail.gmail.com Whole thread Raw |
In response to | Re: [PoC] Improve dead tuple storage for lazy vacuum (Masahiko Sawada <sawada.mshk@gmail.com>) |
Responses |
Re: [PoC] Improve dead tuple storage for lazy vacuum
|
List | pgsql-hackers |
On Mon, Mar 25, 2024 at 8:07 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > On Mon, Mar 25, 2024 at 3:25 PM John Naylor <johncnaylorls@gmail.com> wrote: > > > > On Fri, Mar 22, 2024 at 12:20 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > - * remaining LP_DEAD line pointers on the page in the dead_items > > - * array. These dead items include those pruned by lazy_scan_prune() > > - * as well we line pointers previously marked LP_DEAD. > > + * remaining LP_DEAD line pointers on the page in the dead_items. > > + * These dead items include those pruned by lazy_scan_prune() as well > > + * we line pointers previously marked LP_DEAD. > > > > Here maybe "into dead_items". - * remaining LP_DEAD line pointers on the page in the dead_items. + * remaining LP_DEAD line pointers on the page into the dead_items. Let me explain. It used to be "in the dead_items array." It is not an array anymore, so it was changed to "in the dead_items". dead_items is a variable name, and names don't take "the". "into dead_items" seems most natural to me, but there are other possible phrasings. > > > > Did you try it with 1MB m_w_m? > > > > > > I've incorporated the above comments and test results look good to me. > > > > Could you be more specific about what the test was? > > Does it work with 1MB m_w_m? > > If m_w_m is 1MB, both the initial and maximum segment sizes are 256kB. > > FYI other test cases I tested were: > > * m_w_m = 2199023254528 (maximum value) > initial: 1MB > max: 128GB > > * m_w_m = 64MB (default) > initial: 1MB > max: 8MB If the test was a vacuum, how big a table was needed to hit 128GB? > > The existing comment slipped past my radar, but max_bytes is not a > > limit, it's a hint. Come to think of it, it never was a limit in the > > normal sense, but in earlier patches it was the criteria for reporting > > "I'm full" when asked. > > Updated the comment. + * max_bytes is not a limit; it's used to choose the memory block sizes of + * a memory context for TID storage in order for the total memory consumption + * not to be overshot a lot. The caller can use the max_bytes as the criteria + * for reporting whether it's full or not. This is good information. I suggest this edit: "max_bytes" is not an internally-enforced limit; it is used only as a hint to cap the memory block size of the memory context for TID storage. This reduces space wastage due to over-allocation. If the caller wants to monitor memory usage, it must compare its limit with the value reported by TidStoreMemoryUsage(). Other comments: v79-0002 looks good to me. v79-0003: "With this commit, when creating a shared TidStore, a dedicated DSA area is created for TID storage instead of using the provided DSA area." This is very subtle, but "the provided..." implies there still is one. -> "a provided..." + * Similar to TidStoreCreateLocal() but create a shared TidStore on a + * DSA area. The TID storage will live in the DSA area, and a memory + * context rt_context will have only meta data of the radix tree. -> "the memory context" I think you can go ahead and commit 0002 and 0003/4. v79-0005: - bypass = (vacrel->lpdead_item_pages < threshold && - vacrel->lpdead_items < MAXDEADITEMS(32L * 1024L * 1024L)); + bypass = (vacrel->lpdead_item_pages < threshold) && + TidStoreMemoryUsage(vacrel->dead_items) < (32L * 1024L * 1024L); The parentheses look strange, and the first line shouldn't change without a good reason. - /* Set dead_items space */ - dead_items = (VacDeadItems *) shm_toc_lookup(toc, - PARALLEL_VACUUM_KEY_DEAD_ITEMS, - false); + /* Set dead items */ + dead_items = TidStoreAttach(shared->dead_items_dsa_handle, + shared->dead_items_handle); I feel ambivalent about this comment change. The original is not very descriptive to begin with. If we need to change at all, maybe "find dead_items in shared memory"? v79-0005: As I said earlier, Dilip Kumar reviewed an earlier version. v79-0006: vac_work_mem should also go back to being an int.
pgsql-hackers by date: