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 1iEKxa-0003NQ-Qa for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 22:13:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iEKxZ-0006XV-Ex for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Sep 2019 22:13:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEKxY-0006Wt-VU for pgsql-hackers@lists.postgresql.org; Sat, 28 Sep 2019 22:13:01 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iEKxS-0006oU-1t for pgsql-hackers@postgresql.org; Sat, 28 Sep 2019 22:12:59 +0000 Received: by mail-wm1-x343.google.com with SMTP id f22so8897566wmc.2 for ; Sat, 28 Sep 2019 15:12:53 -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=Q6vvH5ndyKx1DvEGmaM3rOi/bB6bK662HzoXj2htK1U=; b=A4JhZMDfUEIHYUHFaDFHQ6jYiDmXXgnzvpGyviNnsNImcMY7MD3Hz6iIfz17HHMyR3 byuFm542ugIl1EGaVb1yx7F65RV9WDY5Pd6iWfac5lDA4jRh1otrTbRS60ImJ7V93l6b qgEPPDfrwgHAv8DGpRcArsVeznWHxIQsp4Eq0DKSp07BKXW5iP++Togy3C5rH4YT1jpC qdjcA7MkVBcvDjG8LVNAVlAFmxvx6ddyGeZprPg3hYOLFu8yWIlxAG1yk4nrepeymWuO i5KBMMTdiyxWvP43P7m0MlqKb6Y3H69IJfCLuy7MwRDdLvzlOhcL+KcgsBM0upBT0eLP nvDQ== 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=Q6vvH5ndyKx1DvEGmaM3rOi/bB6bK662HzoXj2htK1U=; b=TZ7+ky0xwZmXmwNuZgdIl4PcSmPRE30y85yaXLxFImEzBmN6u9IqIkS2BffRHdrD37 xf9kDlOr+1Q28q7M8bBqDZtDWi2FLJxX7dvaxyDT3Hj20IvPI76ecgaEvXslYqSrnAHj huWhhDbY+wxmI8dHJ8R4Ti86gIJpctdF2duqbID5Ryy3Ewk37ZAPcAzRTWW0B2IXtqp9 bJfzEnfwnTC6RREI9KCTigXlA+xFqVoIIwiUH1QzofPWM9ZlJZzk4t5oCxuLXxpbufDe 9aGeBClrQes0XNcl8LlERBdS/cLoski7XovfHTkdXbL1uohc0Hx97N9zkPNd5xqfZzAq PZyA== X-Gm-Message-State: APjAAAUkxvqFu98fWdX8qXIy7Qbif3Nt0TgczE1HKSj+p1ni/fnwrgJD dCMhwD6Vp/FY6kNaTPgtsMHGsQ== X-Google-Smtp-Source: APXvYqyy/F1Ox87LXAoTJw5ppwcGsfJW5HKByoBoHOkqmQ990UefBy+BGzJGgUwSZZkphS9pGRhc4g== X-Received: by 2002:a1c:720b:: with SMTP id n11mr11226150wmc.23.1569708772407; Sat, 28 Sep 2019 15:12:52 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id a13sm18971056wrf.73.2019.09.28.15.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2019 15:12:51 -0700 (PDT) Date: Sun, 29 Sep 2019 00:12:49 +0200 From: Tomas Vondra To: Jeff Davis Cc: Melanie Plageman , Soumyadeep Chakraborty , Robert Haas , Pg Hackers , soumyadeep2007@gmail.com Subject: Re: Memory Accounting Message-ID: <20190928221249.mo2jrtlakingnc5e@development> References: <027a129b8525601c6a680d27ce3a7172dab61aab.camel@j-davis.com> <20190724215228.tlyj74ie4l2jn7ji@development> <67f66d2fa39e35aef90093c74531a38dcd5c0f73.camel@j-davis.com> <20190926192244.mk5ru6nkofo7am3h@development> <57780817877d4b40106b248b63261e21a7a56261.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <57780817877d4b40106b248b63261e21a7a56261.camel@j-davis.com> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Sep 26, 2019 at 01:36:46PM -0700, Jeff Davis wrote: >On Thu, 2019-09-26 at 21:22 +0200, Tomas Vondra wrote: >> It's worth mentioning that those bechmarks (I'm assuming we're >> talking >> about the numbers Rober shared in [1]) were done on patches that used >> the eager accounting approach (i.e. walking all parent contexts and >> updating the accounting for them). >> >> I'm pretty sure the current "lazy accounting" patches don't have that >> issue, so unless someone objects and/or can show numbers >> demonstrating >> I'wrong I'll stick to my plan to get this committed soon. > >That was my conclusion, as well. > I was about to commit the patch, but during the final review I've noticed two places that I think are bugs: 1) aset.c (AllocSetDelete) -------------------------- #ifdef CLOBBER_FREED_MEMORY wipe_mem(block, block->freeptr - ((char *) block)); #endif if (block != set->keeper) { context->mem_allocated -= block->endptr - ((char *) block); free(block); } 2) generation.c (GenerationReset) --------------------------------- #ifdef CLOBBER_FREED_MEMORY wipe_mem(block, block->blksize); #endif context->mem_allocated -= block->blksize; Notice that when CLOBBER_FREED_MEMORY is defined, the code first calls wipe_mem and then accesses fields of the (wiped) block. Interesringly enough, the regression tests don't seem to exercise these bits - I've tried adding elog(ERROR) and it still passes. For (2) that's not very surprising because Generation context is only really used in logical decoding (and we don't delete the context I think). Not sure about (1) but it might be because AllocSetReset does the right thing and only leaves behind the keeper block. I'm pretty sure a custom function calling the contexts explicitly would fall over, but I haven't tried. Aside from that, I've repeated the REINDEX benchmarks done by Robert in [1] with different scales on two different machines, and I've measured no difference. Both machines are x86_64, I don't have access to any Power machine at the moment, unfortunately. [1] https://www.postgresql.org/message-id/CA%2BTgmobnu7XEn1gRdXnFo37P79bF%3DqLt46%3D37ajP3Cro9dBRaA%40mail.gmail.com regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services