Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tnxmN-004BNO-FY for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2025 10:39:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tnxmN-002Sos-Ae for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2025 10:39:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tnxmN-002Sok-0O for pgsql-hackers@lists.postgresql.org; Fri, 28 Feb 2025 10:39:37 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tnxmH-0009dX-2H for pgsql-hackers@lists.postgresql.org; Fri, 28 Feb 2025 10:39:37 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-390e3b3d432so1332129f8f.2 for ; Fri, 28 Feb 2025 02:39:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740739173; x=1741343973; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=T2oslELAivwiF+ZjT2mG7uR8qufAP+LlYI7Ixuvlr9I=; b=CXS20sip5EkRHSeKH40wlq9iAstup+u9N3R91fFiEcIUM/LDfzImtJmTojZOPvhk29 p6zS72a5A4HbbNMwH05W3TnBh1btxje7/uIrnhfhue1psA8XzMq1W/G72BzLd9TTu8Uw dbt7YaMjXqASfv+TUgUehM6orBmV5PPg2gnUURpFeY53Cx3qEN/AJrxHfqUUEeITfzlK hx7U5NhHeJoT3VMLsr9o91rHYJbIjn29qQZEZV6UXoWh8xLKVDRJ5nR0x9OotqjcfRPB VPwckaj96rKsh5wks8+0I7X02ysff1J08mGAP5NeNWp24lVa1G+hGYMopcJmwebAla+I LYPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740739173; x=1741343973; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T2oslELAivwiF+ZjT2mG7uR8qufAP+LlYI7Ixuvlr9I=; b=bsDq2Do4wFm8LHLzXVykDdYWQX74ZHqtvClamNB8igW2rRWXfYoOlBqGyOjX2WK/iP rUB3iihbVxHW/TTz/IvsGMksuNWq6jqM1IDtIR0WcHDgatqwbQA/KFQz2JYOWv9OET18 /7hyS+VgIMTaOqlqz7mFT+lPneDp2ABj0tmV+7RthPiVqjrdz5byw0mj1bP/BzaRcHIu dPlOEVCYQDJpzT9bIYU4tYXOz0lDId4FsqJEF4DJXkXOD8fe4M2VTG6sUgFBhqufTd5m gRKckRjQnMfHq6Bsz8fqwn3HJUrarEy/5S30LW/Xw4OjNokWwOjl0Bd14Tz1OGWr49r0 fWfg== X-Gm-Message-State: AOJu0Yyy/Qd/t4h9OKojRxBNeSbW2APSZDCr10eRaPxq38kX0ijW57tg u5S2AYe7PIPe7tdT913YPeIjuLL3ERbiBV9jfLEd7sNscrMeJ+07wzxfog== X-Gm-Gg: ASbGncvZYT78DALaRhR7GNdKMRShwxYRzsjYF9POXRnbkLCXneEwef50wSUv7o5a/rf cfz5dSxbogwATXnwO9fiXe2NT/9643w+Yhy+Z5KR4v9DamynAIup+OaTHm1beToK2v4I0dXSGFH UZJ8VIV7Sx7MoBPsThQihNUt5wa7ij37wdiT08hEmdrWBDVJ56o1PfjQ2JxdVFLHxZILBWhECcS aGSYUZle0PMVypuN5qw0MqJpG2S8T2+df2Ker8SvgllFY3wncjjNmW/qx7bPgNzoS3EFxtZdNzS xGZwIxdCyS+67L4sUqZpzAhdIj4P3BBL+piE9speX/XrFFbDnVQrMmx3pQ5wjKWcv2+R4fwqTA4 7lPqDAgz8uo2srqbkSvNy/gc2d0n2KThQWerhmIdLjNcovXktYKAtWoB+mQ== X-Google-Smtp-Source: AGHT+IEKMfXi2M97p8DtqSqMAyQ7M5wJhme1ZeiCMXDXfrSL6JXg0Kqn8i0H6Z92EGnLwu1V/FSEHw== X-Received: by 2002:a5d:47c2:0:b0:390:e59d:fae9 with SMTP id ffacd0b85a97d-390ec7d2dd4mr2189320f8f.27.1740739172936; Fri, 28 Feb 2025 02:39:32 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-181-182.eu-west-3.compute.amazonaws.com. [15.237.181.182]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47b6cd8sm4739181f8f.44.2025.02.28.02.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 02:39:32 -0800 (PST) Date: Fri, 28 Feb 2025 10:39:31 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [BUG]: the walsender does not update its IO statistics until it exits Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Feb 28, 2025 at 02:41:34PM +0900, Michael Paquier wrote: > On Wed, Feb 26, 2025 at 09:48:50AM +0000, Bertrand Drouvot wrote: > > Yeah I think that makes sense, done that way in the attached. > > > > Speaking about physical walsender, I moved the test to 001_stream_rep.pl instead > > (would also fail without the fix). > > Hmm. I was doing some more checks with this patch, and on closer look > I am wondering if the location you have chosen for the stats reports > is too aggressive: this requires a LWLock for the WAL sender backend > type taken in exclusive mode, with each step of WalSndLoop() taken > roughly each time a record or a batch of records is sent. A single > installcheck with a primary/standby setup can lead to up to 50k stats > report calls. Yeah, what I can observe (installcheck with a primary/standby): - extras flush are called about 70K times. Among those 70K: - about 575 are going after the "have_iostats" check in pgstat_io_flush_cb() - about 575 are going after the PendingBackendStats pg_memory_is_all_zeros() check in pgstat_flush_backend() (makes sense due to the above) - about 575 are going after the PendingBackendStats.pending_io pg_memory_is_all_zeros() check in pgstat_flush_backend_entry_io() (makes sense due to the above) It means that only a very few of them are "really" flushing IO stats. > With smaller records, the loop can become hotter, can't it? Also, > there can be a high number of WAL senders on a single node, and I've > heard of some customers with complex logical decoding deployments with > dozens of logical WAL senders. Isn't there a risk of having this code > path become a point of contention? It seems to me that we should > benchmark this change more carefully, perhaps even reduce the > frequency of the report calls. That sounds a good idea to measure the impact of those extra calls and see if we'd need to mitigate the impacts. I'll collect some data. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com