Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bs26c-0007XV-Dt for pgsql-committers@arkaria.postgresql.org; Thu, 06 Oct 2016 06:24:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bs26b-0001FF-TY for pgsql-committers@arkaria.postgresql.org; Thu, 06 Oct 2016 06:24:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bs26N-000111-C2 for pgsql-committers@postgresql.org; Thu, 06 Oct 2016 06:24:19 +0000 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bs26F-0000aw-4L for pgsql-committers@postgresql.org; Thu, 06 Oct 2016 06:24:17 +0000 Received: by mail-lf0-x231.google.com with SMTP id b75so6569035lfg.3 for ; Wed, 05 Oct 2016 23:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=59ZqfoXwC5w9zB20DHpEZTD6HQiXY38IG/b/zSNa/e8=; b=YQ8MhVCfWKZSf+1kqMeWm9gvDkfEWtlOr/oTHWiHkczZao4sP4IYxUgYBbyPXJE2/v hsgZFsM0AXWnEqnASk0EjXg2G9u/usL0yVp3Kx60LtvGgEU7+gf7iXBBLrApOuEoUetH rk22pjciv47jsRNl3oliIyuTl1JmtvI9zealKY4Gi8bZaHsH8RGaMgl7kpz4X0MpjlSC AkjXV1sQAywzghwNm3Ii6IkJgINspQaiU5ZdwCXcbP7G7se0HM0oXRwiffLDDBoe//ML SzwdOptzOa/gQMN0EmnLN505/OI9onZmFPDBvsCEKF/81YkLtV8FZI+MCJcHhvhHUdfu knkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=59ZqfoXwC5w9zB20DHpEZTD6HQiXY38IG/b/zSNa/e8=; b=gOk8YAvsT9zgNhNwWOVLEOLBh7NOtLDeG9namt5P8a2WtJwDF4ODA5Ko7Ztu1XmyLB cxKBYPA2WGAqzaSYX8pXEhae6qkDU06X8drX4ms4qAyKzyiHWHUBwqdit/mWF1khPVHy kYJPl46ls1Rg0WL8qv60bsy3GqteC376GgeQEJLhzFGLIQPDiR8F8OoINizWVIqIBZs6 gY7JBpou30LyEu/GsMXjKAdi7Nw/C3n0eKJEZ+vH+EUlGvsibBlkFWejla0nhDauGZ6U wywj0+z4c2SgR4q0BVC/PIZstFHu4UwmJNQh/AjS5xBmhZxX5/cqvoTcem4KnjumXgwA TS0A== X-Gm-Message-State: AA6/9RkOALWF4vRJwS09ZgY6XBhqi9EqE0OxKuL/cAEwHE9f6OmYwi9xt1AEBEfN0OoG4A== X-Received: by 10.25.136.198 with SMTP id k189mr5601271lfd.132.1475735047968; Wed, 05 Oct 2016 23:24:07 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id h7sm2258718lfd.24.2016.10.05.23.24.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Oct 2016 23:24:07 -0700 (PDT) Subject: Re: pgsql: Change the way pre-reading in external sort's merge phase works. To: Peter Geoghegan References: Cc: pgsql-committers From: Heikki Linnakangas Message-ID: <76571c58-bd72-eb61-6618-cb6521b12c12@iki.fi> Date: Thu, 6 Oct 2016 09:24:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 10/06/2016 04:23 AM, Peter Geoghegan wrote: > I noticed a simple oversight in this patch. It looks like you missed > one place where state->maxTapes ought to be replaced with > numInputTapes -- the loop that calls LogicalTapeAssignReadBufferSize() > needs that changed too, in order to continue to respect workMem as a > budget. Nope. See the comment above that loop: > /* > * Set the buffers for the tapes. > * > * In a multi-phase merge, the tape that is initially used as an output > * tape, will later be rewound and read from, and should also use a large > * buffer at that point. So we must loop up to maxTapes, not just > * numInputTapes! > * > * If there are fewer runs than tapes, we will set the buffer size also > * for tapes that will go completely unused, but that's harmless. > * LogicalTapeAssignReadBufferSize() doesn't allocate the buffer > * immediately, it just sets the size that will be used, when the tape is > * rewound for read, and the tape isn't empty. > */ > for (tapenum = 0; tapenum < state->maxTapes; tapenum++) > { > int64 numBlocks = blocksPerTape + (tapenum < remainder ? 1 : 0); > > LogicalTapeAssignReadBufferSize(state->tapeset, tapenum, > numBlocks * BLCKSZ); > } - Heikki -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers