pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Peter Geoghegan <pg@heroku.com>
Cc: Claudio Freire <klaussfreire@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Tuplesort merge pre-reading
Date: Wed, 28 Sep 2016 19:04:48 +0300
Message-ID: <0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi> (raw)
In-Reply-To: <CAM3SWZTsD-h5QekxHAS4wziaaVKVHmFwA933tmO_F3nnRyTrvA@mail.gmail.com>
References: <f298f77a-cf06-e70c-d5a4-a20b472b4627@iki.fi>
	<CAM3SWZQ4yzxiytLyATuGjxOeowUOjGNmYh1-q5HFY2HEJzZ_VQ@mail.gmail.com>
	<CAM3SWZR3pArWugB9PGaYjiLDnHDUf+AyW1RCJwCFD-LnGCjtKg@mail.gmail.com>
	<95f5a75d-b6ad-f175-57f2-6e32f745e908@iki.fi>
	<2a1b4071-5f4f-4dce-e74b-1c5575c11608@iki.fi>
	<CAGTBQpZ2mcrRyi5FiifCdAFEnznWNLA8Dx-8H6prLw3sECSxMg@mail.gmail.com>
	<CAGTBQpYyBLL07s8zyddo7DSDZfnV1-8huwNwZp7T-UGS58_-4Q@mail.gmail.com>
	<41adf9c3-0659-16e2-e06e-494826b0c969@iki.fi>
	<49817174-c2b6-1378-3d3e-285d270f8fcc@iki.fi>
	<CAM3SWZQrU12mog=TG9jvNOpeUL5Krk9N1Y8GmsLGTGRBJui-aQ@mail.gmail.com>
	<7f7d8271-112c-66a0-8194-8568091e98ad@iki.fi>
	<CAM3SWZQVpNErrnNv-N0YSDpPqPcRAaQ0uth5Td06+FqhUigkdQ@mail.gmail.com>
	<1541ef84-c2e4-26b6-03a3-19d22589caa2@iki.fi>
	<CAM3SWZTsD-h5QekxHAS4wziaaVKVHmFwA933tmO_F3nnRyTrvA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 09/28/2016 06:05 PM, Peter Geoghegan wrote:
> On Thu, Sep 15, 2016 at 9:51 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> I don't think it makes much difference in practice, because most merge
>> passes use all, or almost all, of the available tapes. BTW, I think the
>> polyphase algorithm prefers to do all the merges that don't use all tapes
>> upfront, so that the last final merge always uses all the tapes. I'm not
>> 100% sure about that, but that's my understanding of the algorithm, and
>> that's what I've seen in my testing.
>
> Not sure that I understand. I agree that each merge pass tends to use
> roughly the same number of tapes, but the distribution of real runs on
> tapes is quite unbalanced in earlier merge passes (due to dummy runs).
> It looks like you're always using batch memory, even for non-final
> merges. Won't that fail to be in balance much of the time because of
> the lopsided distribution of runs? Tapes have an uneven amount of real
> data in earlier merge passes.

How does the distribution of the runs on the tapes matter?

>> +   usedBlocks = 0;
>> +   for (tapenum = 0; tapenum < state->maxTapes; tapenum++)
>> +   {
>> +       int64       numBlocks = blocksPerTape + (tapenum < remainder ? 1 : 0);
>> +
>> +       if (numBlocks > MaxAllocSize / BLCKSZ)
>> +           numBlocks = MaxAllocSize / BLCKSZ;
>> +       LogicalTapeAssignReadBufferSize(state->tapeset, tapenum,
>> +                                       numBlocks * BLCKSZ);
>> +       usedBlocks += numBlocks;
>> +   }
>> +   USEMEM(state, usedBlocks * BLCKSZ);
>
> I'm basically repeating myself here, but: I think it's incorrect that
> LogicalTapeAssignReadBufferSize() is called so indiscriminately (more
> generally, it is questionable that it is called in such a high level
> routine, rather than the start of a specific merge pass -- I said so a
> couple of times already).

You can't release the tape buffer at the end of a pass, because the 
buffer of a tape will already be filled with data from the next run on 
the same tape.

- Heikki



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (61+ messages)  latest in thread

Message-ID: <0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi>
Permalink:  ../0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi/
Also on:    postgresql.org/message-id/0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: hlinnaka@iki.fi, pg@heroku.com, klaussfreire@gmail.com
  Subject: Re: Tuplesort merge pre-reading
  In-Reply-To: <0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi>
  References: <f298f77a-cf06-e70c-d5a4-a20b472b4627@iki.fi> <CAM3SWZQ4yzxiytLyATuGjxOeowUOjGNmYh1-q5HFY2HEJzZ_VQ@mail.gmail.com> <CAM3SWZR3pArWugB9PGaYjiLDnHDUf+AyW1RCJwCFD-LnGCjtKg@mail.gmail.com> <95f5a75d-b6ad-f175-57f2-6e32f745e908@iki.fi> <2a1b4071-5f4f-4dce-e74b-1c5575c11608@iki.fi> <CAGTBQpZ2mcrRyi5FiifCdAFEnznWNLA8Dx-8H6prLw3sECSxMg@mail.gmail.com> <CAGTBQpYyBLL07s8zyddo7DSDZfnV1-8huwNwZp7T-UGS58_-4Q@mail.gmail.com> <41adf9c3-0659-16e2-e06e-494826b0c969@iki.fi> <49817174-c2b6-1378-3d3e-285d270f8fcc@iki.fi> <CAM3SWZQrU12mog=TG9jvNOpeUL5Krk9N1Y8GmsLGTGRBJui-aQ@mail.gmail.com> <7f7d8271-112c-66a0-8194-8568091e98ad@iki.fi> <CAM3SWZQVpNErrnNv-N0YSDpPqPcRAaQ0uth5Td06+FqhUigkdQ@mail.gmail.com> <1541ef84-c2e4-26b6-03a3-19d22589caa2@iki.fi> <CAM3SWZTsD-h5QekxHAS4wziaaVKVHmFwA933tmO_F3nnRyTrvA@mail.gmail.com> <0c0b80fc-9dea-c031-ce51-2781edefad4d@iki.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox