Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btsi2-0003FJ-ME for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Oct 2016 08:46:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btsi2-0005fa-9J for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Oct 2016 08:46:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btsgc-0003Ug-0B for pgsql-hackers@postgresql.org; Tue, 11 Oct 2016 08:45:22 +0000 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1btsgZ-0004pK-Ip for pgsql-hackers@postgresql.org; Tue, 11 Oct 2016 08:45:21 +0000 Received: by mail-lf0-x22e.google.com with SMTP id l131so29023674lfl.2 for ; Tue, 11 Oct 2016 01:45:19 -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=Q8rjr0I+aDT8A/qd8D8x68131QdLuZgcJiFfAm0BKcs=; b=bfHxS6SDYOLmEBuS2iYGjurmCylZFufXRjdNX/IgjLojJLUDnGfMCmJNK9W+GeKQJq mrbU15C0LoEishBzED900HUgnwsh9wqDp0uyBwOwQi/BacINkQoEGe4sVkhCbZiFxnrA XZG/0vdq+Gi/313F7UbeD5OzofCEvAhrvfXwDYhm3SGoG9pvxGaFSmot7LQH6j11oAbe QXvU2lnovitAjTa9yKza9DLV5XeEhexV21qjBfBx9QHGdyIOasJ256J8SApS9dN4Ugj4 WurH1qnY3xdlnv7sv54lhN9tODxi06G+V/9MsqPONk3nXcJQGEs9X9xFp/q/wJkjrmuc HFcQ== 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=Q8rjr0I+aDT8A/qd8D8x68131QdLuZgcJiFfAm0BKcs=; b=fk5Fe9J33+FSV2FquGXLrmusU8Tkb/ZkfdH+3SLNDkOnceG3IvjerPlSgpRwOiKrhA cLh0WNsi3MXpXP7bnGTZWVVkWfPpM8sss1GiTurh9fZwR7K65yo44ZUj/4qEiXiDjxuz CHhupyqNv3lAWbyy+xy8JFYgbNcr42dbRdnoGXMLSKFBnLgtulIwWun8ARvGYitAwP4o K+wHLvTHsXs7aiVhttSpDzIzx4FsusfPRyhDvvlTrI5OKxAjrNaAslZrsZBuj1XCjheB pOX4Kxt2fN7ucg1qJTqmJkxr5xhD3r350K8MQWkLrE+tr0ece3B64BafavkfBSrOBNJp feAA== X-Gm-Message-State: AA6/9RlngKvEfav/Jw5663dSVLHASYf6Y/Ha7xElO0jV7Su/Rhua4fVVIH/VYSQZk4VxGA== X-Received: by 10.25.166.196 with SMTP id p187mr1592725lfe.48.1476175517430; Tue, 11 Oct 2016 01:45:17 -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 s63sm502150lja.49.2016.10.11.01.45.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Oct 2016 01:45:16 -0700 (PDT) Subject: Re: memory leak in e94568ecc10 (pre-reading in external sort) To: Peter Geoghegan References: <7303da46-daf7-9c68-3cc1-9f83235cf37e@2ndquadrant.com> <9f997ab1-5f3a-cf79-b92b-dc170ec75043@iki.fi> <0f607c4b-df23-353e-bf56-c0389d28495f@iki.fi> Cc: Tomas Vondra , Pg Hackers From: Heikki Linnakangas Message-ID: Date: Tue, 11 Oct 2016 11:45:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 10/11/2016 12:56 AM, Peter Geoghegan wrote: > Also, something about trace_sort here: > >> +#ifdef TRACE_SORT >> + if (trace_sort) >> + elog(LOG, "using " INT64_FORMAT " KB of memory for read buffers among %d input tapes", >> + (state->availMem) / 1024, numInputTapes); >> +#endif >> + >> + state->read_buffer_size = state->availMem / numInputTapes; >> + USEMEM(state, state->availMem); > > Maybe you should just make the trace_sort output talk about blocks at > this point? With # of blocks, you then have to mentally divide by 8 to get the actual memory used. I think kB is nicer in messages that are meant to be read by humans. The bigger problem with this message is that it's not very accurate anymore. The actual amount of memory used is rounded down, and capped by MaxAllocSize*numInputTapes. And would it be better to print the per-tape buffer size, rather than the total? - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers