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 1pj3PS-0002do-5t for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Apr 2023 19:30:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pj3PR-0002Ex-2o for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Apr 2023 19:30:37 +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 1pj3PQ-0002Eo-JG for pgsql-hackers@lists.postgresql.org; Sun, 02 Apr 2023 19:30:36 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pj3PO-0002mO-2F for pgsql-hackers@postgresql.org; Sun, 02 Apr 2023 19:30:35 +0000 Received: by mail-pl1-x635.google.com with SMTP id kc4so26055842plb.10 for ; Sun, 02 Apr 2023 12:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680463833; 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=0Pvw4rfvkURK49E6d4a80AGTLlnaMp1RJZ8LoiCqJKw=; b=K0wjgCnqw25y8kTfEvm+MhYnX7MLoSqV0c6njeqhWIEFYUDZ0CcZlyQpLHW9xhFdLK zKGyajpzQM9BavnMVPYSn6cvDi/Gky0zl4kw2Yiyz5vJ7YKmQfeLuojIhmN6T0lYa2Iv TTYWHceYEBqu8IKt7V6jVSM+pOaGpJv0J5qtla34rhS8noUT8XKB3JzejuwTltc2War+ NmWU0imEHM9hxbL7hm6dfypH6ZndnS/IB4VqpWJaJO+PFbfOCVEZ8vD3UCqxUL8o53ch N4hTCPGohm6k88tWsn4QODNvJMxxEHFjZ/hmcKE/8wcWFaVoSMDwAa87VuyUn7KhQGHu L5jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680463833; 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=0Pvw4rfvkURK49E6d4a80AGTLlnaMp1RJZ8LoiCqJKw=; b=cPiC2dXfsg8kh71lXzkb7MUo7ma96nK8UxQU8j05jvuNXIK/5O1wY6/BEe4cKVF4SB eIB6Wqq9h/f7Ja/YT0e/Lg5p7qMw+bHQIKFySrIfbiZanxF+U+BA5nkHW7yF8ffCz0ZI kE8Y9kNOcsnkYztzjzK3oWxBRPDW22LypQ4UU6A9fX7H70b69L+81hBOnEQBQD9BsF9+ AvxrPpANg9HJmgOvsMAX3K6mC6y37Xu3SynqQDjCUPaqbc9jS4oJ0h4KjRxGzNI6/y0j laodaLkcQ2mSTWMy912S0Jb6EiThAn8PE2JIG8db4bpwSCHw+jqiBdDBtgoBJCsW0a8C htqQ== X-Gm-Message-State: AAQBX9eiBhcGa2kemsQxBGBhmVQIx/yw53HM0y0gD78FiwhoxxG8Z7sx Uz7iHo5knTvXS8HDEWpG1uM= X-Google-Smtp-Source: AKy350Yi8PYzfOWk0JMm+s3uAZ2Q/fYnjhtiRyFwOKxOGvvdd3mMsR4a0004wV88echwPS5K58aMfw== X-Received: by 2002:a17:903:42cb:b0:1a2:76b6:c276 with SMTP id jy11-20020a17090342cb00b001a276b6c276mr14005608plb.28.1680463832787; Sun, 02 Apr 2023 12:30:32 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id je22-20020a170903265600b001a0742b0806sm5117551plb.108.2023.04.02.12.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 12:30:32 -0700 (PDT) Date: Sun, 2 Apr 2023 12:30:30 -0700 From: Nathan Bossart To: Tom Lane Cc: Bharath Rupireddy , Robert Haas , Andres Freund , "Bossart, Nathan" , Maxim Orlov , Amul Sul , Bruce Momjian , "pgsql-hackers@postgresql.org" Subject: Re: O(n) tasks cause lengthy startups and checkpoints Message-ID: <20230402193030.GA25018@nathanxps13> References: <20221130051833.GB1677223@nathanxps13> <20221201214026.GA1799688@nathanxps13> <20221202191507.GA2277157@nathanxps13> <20230203054808.GA83788@nathanxps13> <20230217234344.GA3357392@nathanxps13> <1031491.1680457205@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1031491.1680457205@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Apr 02, 2023 at 01:40:05PM -0400, Tom Lane wrote: > I took a brief look through v20, and generally liked what I saw, > but there are a few things troubling me: Thanks for taking a look. > * The comments for CustodianEnqueueTask claim that it won't enqueue an > already-queued task, but I don't think I believe that, because it stops > scanning as soon as it finds an empty slot. That data structure seems > quite oddly designed in any case. Why isn't it simply an array of > need-to-run-this-one booleans indexed by the CustodianTask enum? > Fairness of dispatch could be ensured by the same state variable that > CustodianGetNextTask already uses to track which array element to > inspect next. While that wouldn't guarantee that tasks A and B are > dispatched in the same order they were requested in, I'm not sure why > we should care. That works. Will update. > * I don't much like cust_lck, mainly because you didn't bother to > document what it protects (in general, CustodianShmemStruct deserves > more than zero commentary). Do we need it at all? If the task-needed > flags were sig_atomic_t not bool, we probably don't need it for the > basic job of tracking which tasks remain to be run. I see that some > of the tasks have possibly-non-atomically-assigned parameters to be > transmitted, but restricting cust_lck to protect those seems like a > better idea. Will do. > * Not quite convinced about handle_arg_func, mainly because the Datum > API would be pretty inconvenient for any task with more than one arg. > Why do we need that at all, rather than saying that callers should > set up any required parameters separately before invoking > RequestCustodian? I had done it this way earlier, but added the Datum argument based on feedback upthread [0]. It presently has only one proposed use, anyway, so I think it would be fine to switch it back for now. > * Why does LookupCustodianFunctions think it needs to search the > constant array? The order of the tasks in the array isn't guaranteed to match the order in the CustodianTask enum. > * The original proposal included moving RemovePgTempFiles into this > mechanism, which I thought was probably the most useful bit of the > whole thing. I'm sad to see that gone, what became of it? I postponed that based on advice from upthread [1]. I was hoping to start a dedicated thread for that immediately after the custodian infrastructure was committed. FWIW I agree that it's the most useful task of what's proposed thus far. [0] https://postgr.es/m/20220703172732.wembjsb55xl63vuw%40awork3.anarazel.de [1] https://postgr.es/m/CANbhV-EagKLoUH7tLEfg__VcLu37LY78F8gvLMzHrRZyZKm6sw%40mail.gmail.com -- Nathan Bossart Amazon Web Services: https://aws.amazon.com