pgsql: Re-bin segment when memory pages are freed.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Re-bin segment when memory pages are freed.
Date: 2023-07-04 04:19:15
Message-ID: E1qGXVT-001ojp-Aq@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Re-bin segment when memory pages are freed.

It's OK to be lazy about re-binning memory segments when allocating,
because that can only leave segments in a bin that's too high. We'll
search higher bins if necessary while allocating next time, and
also eventually re-bin, so no memory can become unreachable that way.

However, when freeing memory, the largest contiguous range of free pages
might go up, so we should re-bin eagerly to make sure we don't leave the
segment in a bin that is too low for get_best_segment() to find.

The re-binning code is moved into a function of its own, so it can be
called whenever free pages are returned to the segment's free page map.

Back-patch to all supported releases.

Author: Dongming Liu <ldming101(at)gmail(dot)com>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com> (earlier version)
Reviewed-by: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAL1p7e8LzB2LSeAXo2pXCW4%2BRya9s0sJ3G_ReKOU%3DAjSUWjHWQ%40mail.gmail.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1605623ec6868aab1de2ddf992c36a1fcf9ad555

Modified Files
--------------
src/backend/utils/mmgr/dsa.c | 65 +++++++++++++++++++++++++++++---------------
1 file changed, 43 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2023-07-04 05:19:43 Re: pgsql: Fix search_path to a safe value during maintenance operations.
Previous Message Thomas Munro 2023-07-04 04:19:03 pgsql: Re-bin segment when memory pages are freed.