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 1sRcXD-00H6Qq-9b for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2024 18:59:23 +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 1sRcXB-008Ddk-CH for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jul 2024 18:59:21 +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 1sRcXA-008Ddc-Vk for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2024 18:59:21 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sRcX8-001Ptg-FZ for pgsql-hackers@lists.postgresql.org; Wed, 10 Jul 2024 18:59:19 +0000 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7fa51e8608aso4450639f.0 for ; Wed, 10 Jul 2024 11:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720637958; x=1721242758; 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=0abtO8qxTU4g6qoQgS3nmn5bE5O0yHHqcx47NjojESQ=; b=jSvMA+ElgzNstM1ESMYvuBgzZ/r3wgma6gJzeTLBhhuG03xJELgtT7Q1eOXuUukYlu TK8K+k4UDhXrQvRn/fyZZGrHbqbK4+5H6JxYXrbaU9wjvWFwWQoz9Qgg7wqvrbIci0cE j57F1TUMiP0+uahhpVz8OUDBjhUJb7tmqPm5F2afVoeOUr2BDq2Yj6rVW2cOesPx8BmZ j9DACKmiPAWsGjWZsjgLnxubghHn7y1AGtLxkMxmQSSOYdild13W9jFsVnlPvodbnxPM r8jIXllHBuNE1bux581lPOm/gYJaJKuZ1gx2ZlsvikLuzAEHPHv21QdfgUBTnq+Tmx8Z LEyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720637958; x=1721242758; 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=0abtO8qxTU4g6qoQgS3nmn5bE5O0yHHqcx47NjojESQ=; b=vFPtjxg+5X3hCuNPVrU+8NColopInk5XJZtRgcceVBCtKUmIiufPJRaA4tlPTpZ2Q0 BSYl+9AnmrimBmF+lm3cVtiKZAwnIXeqH3qmixLPIPYaL2UZFHfGhm1iUoWD6KNH5xPg uXDOe7FTaVPFcnKd6T4JS/tOeWoeQlRPYrmcoanHhkX5p0tcb5rhToJlRPG4AFr48fzm IbjB+Hi4PrOEFXqDV4Rpy4zujDr3ZDxbs6qyzFWFYUpSk1oPn8pxOYf2AVUCwsf0nwsn muv2tCnvKv9vlhrtgctw4+niedHwdrlWRJAekFQcB3sf/grYb4GFUzz+wPFmB+OXyNhS WxBw== X-Gm-Message-State: AOJu0YxqDXFQZAVoPHs3SFPqDIOdzWhAp2mH1Xu68NHcWSMtTu1ZBBfd KwDwJEoXK0yPzbSBc5JoyvE95VUni45QzLuL/gpxTfW1naKK35Qdf/9YtdEo X-Google-Smtp-Source: AGHT+IGffPLR9AWbuQl7VRekT4yUEbCGM4YGeNW1nyL/85f9hhjvjElB7sQud1zQFAq0+8u3UiAMlA== X-Received: by 2002:a05:6602:6d1a:b0:7f9:c953:c754 with SMTP id ca18e2360f4ac-7fffe62c3d3mr927789339f.3.1720637957755; Wed, 10 Jul 2024 11:59:17 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-7ffed680f78sm134140639f.50.2024.07.10.11.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 11:59:17 -0700 (PDT) Date: Wed, 10 Jul 2024 13:59:15 -0500 From: Nathan Bossart To: Antonin Houska Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Missed opportunity for bsearch() in TransactionIdIsCurrentTransactionId()? Message-ID: References: <36977.1720623613@antos> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36977.1720623613@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 10, 2024 at 05:00:13PM +0200, Antonin Houska wrote: > I don't quite understand why TransactionIdIsCurrentTransactionId() implements > binary search in ParallelCurrentXids "from scratch" instead of using > bsearch(). I believe there are a number of open-coded binary searches in the tree. My concern with switching them to bsearch() would be the performance impact of using a function pointer for the comparisons. Perhaps we could add a couple of inlined binary search implementations for common types to replace many of the open-coded ones. -- nathan