Re: Questions/Observations related to Gist vacuum

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Questions/Observations related to Gist vacuum
Date: 2019-10-18 04:04:28
Message-ID: CAFiTN-swvL7Rtiw0c9JeLhkeZ1X9SZ904FErs-9nL=MzcSdxWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 17, 2019 at 6:32 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> On Thu, 17 Oct 2019, 14:59 Amit Kapila, <amit(dot)kapila16(at)gmail(dot)com> wrote:
>>
>> On Thu, Oct 17, 2019 at 1:47 PM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>> >
>> > On Thu, Oct 17, 2019 at 12:27 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>> > >
>> > > On 17/10/2019 05:31, Amit Kapila wrote:
>> > > >
>> > > > The patch looks good to me. I have slightly modified the comments and
>> > > > removed unnecessary initialization.
>> > > >
>> > > > Heikki, are you fine me committing and backpatching this to 12? Let
>> > > > me know if you have a different idea to fix.
>> > >
>> > > Thanks! Looks good to me. Did either of you test it, though, with a
>> > > multi-pass vacuum?
>> >
>> > From my side, I have tested it with the multi-pass vacuum using the
>> > gist index and after the fix, it's using expected memory context.
>> >
>>
>> I have also verified that, but I think what additionally we can test
>> here is that without the patch it will leak the memory in
>> TopTransactionContext (CurrentMemoryContext), but after patch it
>> shouldn't leak it during multi-pass vacuum.
>>
>> Make sense to me, I will test that by tomorrow.

I have performed the test to observe the memory usage in the
TopTransactionContext using the MemoryContextStats function from gdb.

For testing this, in gistvacuumscan every time, after it resets the
page_set_context, I have collected the sample. I have collected 3
samples for both the head and the patch. We can clearly see that on
the head the memory is getting accumulated in the
TopTransactionContext whereas with the patch there is no memory
getting accumulated.

head:
TopTransactionContext: 1056832 total in 2 blocks; 3296 free (5
chunks); 1053536 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1056944 bytes in 2 blocks; 3296 free (5 chunks); 1053648 used

TopTransactionContext: 1089600 total in 4 blocks; 19552 free (14
chunks); 1070048 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1089712 bytes in 4 blocks; 19552 free (14 chunks); 1070160 used

TopTransactionContext: 1122368 total in 5 blocks; 35848 free (20
chunks); 1086520 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1122480 bytes in 5 blocks; 35848 free (20 chunks); 1086632 used

With Patch:
TopTransactionContext: 1056832 total in 2 blocks; 3296 free (1
chunks); 1053536 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1056944 bytes in 2 blocks; 3296 free (1 chunks); 1053648 used

TopTransactionContext: 1056832 total in 2 blocks; 3296 free (1
chunks); 1053536 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1056944 bytes in 2 blocks; 3296 free (1 chunks); 1053648 used

TopTransactionContext: 1056832 total in 2 blocks; 3296 free (1
chunks); 1053536 used
GiST VACUUM page set context: 112 total in 0 blocks (0 chunks); 0
free (0 chunks); 112 used
Grand total: 1056944 bytes in 2 blocks; 3296 free (1 chunks); 1053648 used

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2019-10-18 04:11:41 Re: Questions/Observations related to Gist vacuum
Previous Message M Tarkeshwar Rao 2019-10-18 03:47:49 Can you please tell us how set this prefetch attribute in following lines.