Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxHLs-0000BQ-3X for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Nov 2022 00:41:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oxHLq-0007hs-Sm for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Nov 2022 00:41:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oxHLq-0007hj-DT for pgsql-hackers@lists.postgresql.org; Tue, 22 Nov 2022 00:41:26 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oxHLn-0002J3-Sz for pgsql-hackers@postgresql.org; Tue, 22 Nov 2022 00:41:25 +0000 Received: by mail-pf1-x42f.google.com with SMTP id v28so12847607pfi.12 for ; Mon, 21 Nov 2022 16:41:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=zGfcHkyUhfLSHLhqKOt/BewXCHWeb21cBcVtLaaP9fU=; b=X6vVRUR8HzNZnQ9FuxgoChIzLKk046h/998DquzZb27lQgCZC0Pen1Vpd6mwFvLGiM 9yXejyvX6b1yxcklApmpx6LKGzjGgGPM1gmpNxvqB6sWm2vgqZcPIWkZpg4VycMi8NFJ PYvHyoRdUUbXZJq0wId7QooYnfKWlnT5pwAA46/13lcQ9y9oArhgbOO+iAPk21HjasLo 8sjCQJbtYKPI2Qjt0RyrO0gJN3sz6mFwowlumVcGPAPNu4ya97TqbL9tG+sUe4nmjWsn tyPhOYxcTq5Dwau2vRZQYyON3fIsD6cCcsVCusXS6ERYphvIgp+Js9Bm+d0cui6ApcO4 mbfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zGfcHkyUhfLSHLhqKOt/BewXCHWeb21cBcVtLaaP9fU=; b=M1aiT2UpWfvSkg6SSLaHByids96eWncHfW0Jv17V/ff2qMKGICgMp6DA2/tl8qLEak StEE8Fom4O74M9cegc8ppAGtZCcBWy6jmWZyMOi6i2dhTf6WyHaZxAXWOZeHOA3lEscB JrTzsXr09IkC8wnXyF2AtVYdkpU9Q+osKh0neMcAiyjFnbDScrHzqdfw6Mp7xLYlhZPM aak8RiN7uyU+1lb+0NpPakf5FnvwqXcdlfmB085bpKPpYU9NaHizik2gcezEfpv2NrvT nd/ow4218p4PWfN88f/l3Usx0PLOhP7J14BQjXNecDTfU+t/yK/zO7YXSfWUmOH7gFvw Q87w== X-Gm-Message-State: ANoB5pmgnkXCd9uexGaBneDZJMtUB7f4R3sKj0aR/KIpx2IawM47Avvb 1yfQ0bOJ4R6o5ViK/SOqbZHka0XeBHk= X-Google-Smtp-Source: AA0mqf4xI4ET4j0BdS4H+YRGwjM7YEIBe32vuHO59SuX0D5XHtKQejz/pMKgBdJtqpDwx1S8K+nFFw== X-Received: by 2002:a63:e30c:0:b0:470:8098:f0de with SMTP id f12-20020a63e30c000000b004708098f0demr1225170pgh.527.1669077682339; Mon, 21 Nov 2022 16:41:22 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id 139-20020a630591000000b0046fb6e0e691sm8180984pgf.6.2022.11.21.16.41.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 16:41:21 -0800 (PST) Date: Mon, 21 Nov 2022 16:41:19 -0800 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: wake up logical workers after ALTER SUBSCRIPTION Message-ID: <20221122004119.GA132961@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi hackers, While working on avoiding unnecessary wakeups in logical/worker.c (as was done for walreceiver.c in 05a7be9), I noticed that the tests began taking much longer. This seems to be caused by the reduced frequency of calls to maybe_reread_subscription() in LogicalRepApplyLoop(). Presently, LogicalRepApplyLoop() only waits for up to a second, so the subscription info is re-read by workers relatively frequently. If LogicalRepApplyLoop() sleeps for longer, the subscription info may not be read for much longer. I think the fix for this problem can be considered independently, as relying on frequent wakeups seems less than ideal, and the patch seems to provide a small improvement even before applying the avoid-unnecessary-wakeups patch. On my machine, the attached patch improved 'check-world -j8' run time by ~12 seconds (from 3min 8sec to 2min 56 sec) and src/test/subscription test time by ~17 seconds (from 139 seconds to 122 seconds). I put the new logic in launcher.c, but it might make more sense to put it in logical/worker.c. I think that might require some new #includes in a couple of files, but otherwise, the patch would likely look about the same. Thoughts? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --C7zPtVaVf+AK4Oqc Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-wake-up-logical-workers-after-ALTER-SUBSCRIPTION.patch"