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 1t8L5g-003ZDw-G3 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 15:03:31 +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 1t8L5d-00EZb1-TO for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Nov 2024 15:03:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8L5d-00EZat-K2 for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 15:03:30 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8L5b-000JoY-CY for pgsql-hackers@lists.postgresql.org; Tue, 05 Nov 2024 15:03:28 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso66077335e9.0 for ; Tue, 05 Nov 2024 07:03:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730819006; x=1731423806; 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=X7wN1cXvFW7OJ/+3lxj5UT2G4ZU96tKJw8Vso2GS170=; b=Ailp2zaHWNg9SUzN71j57R/yXU1GH+a2WWwxWo82gbnfYaAZk5CMtPRHkG7S89zZY0 mnntzNOOwf9CE2TDoxLIjDeStCjpg8o/MVQk9uEHWSUitU+QZXzcXzsLvA7giPUbxVea fTYlwQXCEW/9q+D1M6HbxtZ1nPREpSIoCyFGZCaaepFanc76TyHBOCaj48mk7VRtqfWr GTt6xmdZ3TvFFQeXOI42sH79Jz6K+89Qv/axE7FsvGsQ7fWt3v66MgpQVyKaeM++ZDIC qiRjBCo1CLX0mcp7L/5xO7o86tHByvnn+gHOZZ7oc+UXagfueKVIU5ARjWZnnI8xRq8C O9Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730819006; x=1731423806; 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=X7wN1cXvFW7OJ/+3lxj5UT2G4ZU96tKJw8Vso2GS170=; b=l6r5S378T+VTieGVaFKeD+LxKd2ZW+0qB4xbXlPEv9Qxwwzce7LfbJesBanVryADUf QQjQUS53+ViE16YjoovJBMAI4Hw4ZibCZ81FrL4hY5FHIIWwBpMY67h13C0xhkFB3TzX Bn6lVUi3QpE+YZW3KOqqGVVLQuPQedU47MKAmVX5DAvQPZOvcBnkT5mMxG7E20hTmxJW 6IPwO6P0bLswQFaxY70jzQHFX9gxkvXibziC9eVG6KxsLdGi8dh8Odxx0TuP0JTf5YWm V3ps1PKB0JwkByCvydVQorquJzyW4/JOEnsUS6VJG5SsGMEYCJVvLYv8c+lqExFL7uU7 dofw== X-Forwarded-Encrypted: i=1; AJvYcCXASc0Wzat/KW+6X1ihd3ZXiqPziQvuRSXcvwXGpk8ldTGzQY294q+pGS8WVqbKLfL41fNUzfjB+F5CU0nN@lists.postgresql.org X-Gm-Message-State: AOJu0Ywp+xGQQlFNX+2DrS7W0kEosWwI6pXWEBsNFrIi4EAoGrUvLD3K agGkpT3KEmIgfZLtKMX+WlHOWsXPt0NMnZgCCsazH/iPeTklTXRX X-Google-Smtp-Source: AGHT+IFcBg8s6Uk4tSvlRlw/Ih22WA+CjrWvoL0J24IlK8ZoyI3agA564Gpd9g1Vgv4XRbIdOyrPyQ== X-Received: by 2002:a5d:5e87:0:b0:37d:39d8:b54b with SMTP id ffacd0b85a97d-381c7ae1552mr14467077f8f.58.1730819005430; Tue, 05 Nov 2024 07:03:25 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10d42adsm16390651f8f.40.2024.11.05.07.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 07:03:25 -0800 (PST) Date: Tue, 5 Nov 2024 15:03:23 +0000 From: Bertrand Drouvot To: David Rowley Cc: Ranier Vilela , Michael Paquier , Peter Smith , Peter Eisentraut , Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Subject: Re: define pg_structiszero(addr, s, r) 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 Tue, Nov 05, 2024 at 05:08:41PM +1300, David Rowley wrote: > On Tue, 5 Nov 2024 at 06:39, Ranier Vilela wrote: > > I think we can add a small optimization to this last patch [1]. > > I think if you want to make it faster, you could partially unroll the > inner-most loop, like: > > // size_t * 4 > for (; p < aligned_end - (sizeof(size_t) * 3); p += sizeof(size_t) * 4) > { > if (((size_t *) p)[0] != 0 | ((size_t *) p)[1] != 0 | ((size_t *) > p)[2] != 0 | ((size_t *) p)[3] != 0) > return false; > } Another option could be to use SIMD instructions to check multiple bytes is zero in a single operation. Maybe just an idea to keep in mind and experiment if we feel the need later on. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com