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 1t5igz-007vdR-7y for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Oct 2024 09:39:13 +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 1t5igx-00EguQ-CC for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Oct 2024 09:39:11 +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 1t5igw-00EguI-Ui for pgsql-hackers@lists.postgresql.org; Tue, 29 Oct 2024 09:39:11 +0000 Received: from meesny.iki.fi ([2001:67c:2b0:1c1::201]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t5igu-003ZJw-Kf for pgsql-hackers@lists.postgresql.org; Tue, 29 Oct 2024 09:39:10 +0000 Received: from [192.168.1.110] (dsl-hkibng22-50ddb7-241.dhcp.inet.fi [80.221.183.241]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4Xd4vr6SyRzyVV; Tue, 29 Oct 2024 11:39:03 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1730194746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Xtdw7PrqAXWeJpw9GRI5eSlher9GrGIpNkKTgZx7yY=; b=mYshqzJIOuNxa7LjxImsecdeXYoveZODcbWTxclE4QXJpLJ1006V+8NqI4iELYflboCvQT eDipySz7MEWIZX/gUoSqFfl9a7S2sVlKhGG0bmiIj6hLwbhbOWAAnq6G4bRRB53wmfWQG5 +Yxfso9lkS5GqXvC2NRzfGQ7FqPJtQE= ARC-Seal: i=1; s=meesny; d=iki.fi; t=1730194746; a=rsa-sha256; cv=none; b=o+JoUzbowvLU/S8MTbCecNVwGSabZ6zjXerFsmJHgpbaY5vt6/t/tArD2WmDa2fsWckxWB 6OZ0OTwcEKiEu3opC36ldIDCzwdH8TvM23nSj/ijbFc/ncFSP81OGNla612q9tedNe+HSN XeUm/D7XVtQ/RJHuPVpDwFPGK4TZ2Vg= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1730194746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Xtdw7PrqAXWeJpw9GRI5eSlher9GrGIpNkKTgZx7yY=; b=TGtS6kBf1/pGsF90qs+3N9fAb3zK1PuwOuh7qlkYdrI3PeHZ8FOZASTRk8T8bYW13i9M8z 43BVbgO8jr8IQ1+UYRvfl7D4mD0BmbuQgXV8XV9auJnj1+NcrKOg+ftNp8iZpmZsGwiJZA 9ZUYxeo/TzG9tchKu1H3Nqf7HlAacI8= Message-ID: <2ed3e31e-55ee-41f6-8841-b096a798f504@iki.fi> Date: Tue, 29 Oct 2024 11:39:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: define pg_structiszero(addr, s, r) To: Bertrand Drouvot , Peter Smith Cc: Peter Eisentraut , pgsql-hackers@lists.postgresql.org References: <3023d29e-0fe7-4bec-9028-7f3c0102e437@eisentraut.org> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 29/10/2024 09:54, Bertrand Drouvot wrote: >> https://godbolt.org/z/x9hPWjheq. > > Yeah, I also think that's fine. Peter Smith did some testing in [1] comparing > memcmp and simple loop checking (thanks Peter for the testing!): > > " > Iterate 1000000 times... > check zeros using loop -- elapsed=0.041196s > check zeros using memcmp -- elapsed=0.016407s > " > > So, in this test, the loop is 0.024789s longer means 0.024789s/1000000=24 Nanosecond > slower per comparison (If my math is correct). I believe that test program is bogus. Look at the assembly code; the compiler optimized away the loops. -- Heikki Linnakangas Neon (https://neon.tech)