Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDbGA-0003UJ-Iw for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Sep 2019 21:25:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDbG9-0000MU-Bq for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Sep 2019 21:25:09 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDbG9-0000M6-2y for pgsql-hackers@lists.postgresql.org; Thu, 26 Sep 2019 21:25:09 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDbG1-0002kn-Bp for pgsql-hackers@postgresql.org; Thu, 26 Sep 2019 21:25:07 +0000 Received: by mail-wm1-x341.google.com with SMTP id 3so4030633wmi.3 for ; Thu, 26 Sep 2019 14:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CEBRCzpkmZqdMjM+DrrQIqbywvOy65PeBt1vaSBX3yQ=; b=iPlMyXGmMUdHYqfEC9EC6XiccgmzpqmguT1oc35M3UPh+hzqnD5kvjtRY1o4qrh6pJ 4klDtSn+BXKyZJPuADV9brDau2QO6l8QFWXmOnBdA4UpPRu6BdT2AARyPTYB5vKy7+uT IQkQkPxeaApwPiiDtB8hPx7EnmXezzkpzj7e+UD0xhQz9rteAoehx0824yM4dJvSU7lZ CLHPFEsI/JYH61rd94oZSSZP0WbOzXAHuJxxBi/juMeKD90MCpwikz8PaWXzPdQcRzEy KQp09OEhXAWVGRIQFKVK8Gv6xA9vaGefgqHu2Dtu1HEctLO0pH1jlEVecidbQaKrTHAR IDjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CEBRCzpkmZqdMjM+DrrQIqbywvOy65PeBt1vaSBX3yQ=; b=YkQ3Q1kQN8uisJvI70LnyqJEb68pAocrpTA7jCubGbKHO0CN6lUP85cUmZ13v5lPFR o+h2YpGlOLufYBiDHGsnat5Mr0fcclBKZv5yEL+mVGxwHse2SBzt7WRBv6fhoJe/pYGK TKhg8FKx/U/IF7Rd0ozhy8xm6LKMCBAcGO09SxJG7Y5S5w+1ZGnFRGHDIKihVNmkIn5i LxO3UayJLF0AXYb4oteIowdD9+Sjdt1vo3QKeAXoq4o3XnAYt1wtqb8bw2bZmcS/bPSZ mP7m3drNyulu+FqFXmKly0tzsDesbHK9wt8qzCBtkVfe6Q+yEXfFTHziqOdksluw2+Vs xDxA== X-Gm-Message-State: APjAAAVzqZPBpiZ0gKPzZtAl7xHqr/8LBxG1TLmeAijITZtk8skiJjvt woQcC5fUlHIbypBYg8lbJ9UUbA== X-Google-Smtp-Source: APXvYqxs+i2e3LffjzJFwxqEkZrPwdTtilaEOzXiHZs+fALBEApxvDUPBxr4LCznZKzMYyjKvaMYJg== X-Received: by 2002:a05:600c:110a:: with SMTP id b10mr4464724wma.18.1569533100021; Thu, 26 Sep 2019 14:25:00 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id h125sm6893457wmf.31.2019.09.26.14.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 14:24:58 -0700 (PDT) Date: Thu, 26 Sep 2019 23:24:55 +0200 From: Tomas Vondra To: Alvaro Herrera Cc: Amit Kapila , PostgreSQL Hackers Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions Message-ID: <20190926212455.p6lp3q3lg7jske57@development> References: <20190926193359.GA16585@alvherre.pgsql> <20190926193620.GA16836@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190926193620.GA16836@alvherre.pgsql> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Sep 26, 2019 at 04:36:20PM -0300, Alvaro Herrera wrote: >On 2019-Sep-26, Alvaro Herrera wrote: > >> How certain are you about the approach to measure memory used by a >> reorderbuffer transaction ... does it not cause a measurable performance >> drop? I wonder if it would make more sense to use a separate contexts >> per transaction and use context-level accounting (per the patch Jeff >> Davis posted elsewhere for hash joins ... though I see now that that >> only works fot aset.c, not other memcxt implementations), or something >> like that. > >Oh, I just noticed that that patch was posted separately in its own >thread, and that that improved version does include support for other >memory context implementations. Excellent. > Unfortunately, that won't fly, for two simple reasons: 1) The memory accounting patch is known to perform poorly with many child contexts - this was why array_agg/string_agg were problematic, before we rewrote them not to create memory context for each group. It could be done differently (eager accounting) but then the overhead for regular/common cases (with just a couple of contexts) is higher. So that seems like a much inferior option. 2) We can't actually have a single context per transaction. Some parts (REORDER_BUFFER_CHANGE_INTERNAL_TUPLECID) of a transaction are not evicted, so we'd have to keep them in a separate context. It'd also mean higher allocation overhead, because now we can reuse chunks cross-transaction. So one transaction commits or gets serialized, and we reuse the chunks for something else. With per-transaction contexts we'd lose some of this benefit - we could only reuse chunks within a transaction (i.e. large transactions that get spilled to disk) but not across commits. I don't have any numbers, of course, but I wouldn't be surprised if it was significant e.g. for small transactions that don't get spilled. And creating/destroying the contexts is not free either, I think. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services