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 1rpu4M-009OmY-4y for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 18:01:42 +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 1rpu4L-0012V9-3c for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 18:01:41 +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 1rpu4K-0012V0-Pp for pgsql-hackers@lists.postgresql.org; Thu, 28 Mar 2024 18:01:40 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rpu4F-006v1x-Sr for pgsql-hackers@postgresql.org; Thu, 28 Mar 2024 18:01:38 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-513ccc70a6dso2081427e87.1 for ; Thu, 28 Mar 2024 11:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1711648895; x=1712253695; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LKP3205VA/krnlqaXK8L87jAKCgTJwOgCX0cGrXg7Gk=; b=ZVlrFk6lktOfDzZPth4a47A1f1pEuH0YCoRw/4yhHpvByBSBB2MGYswe+MopIUc/0V bu+7VscCyFbNOl0qvk+ppp7BYcQNZ2x7icTFLgvQrsjsxMh/goU5G3qPWMsulV1ejOgf hu5CdpQLd8OPtrA9Y7JSsUg3vScJZXrsutwTZB3Ue9PNvoy/j6qneNBBajZetoVDOdsX 7BhYyArw1bU0JcHsz8oYWywjSTmaYyldiwOZF2ba/hvgtO7r1EGUvxafXNvZ2p3B21Vb fbwaFqO2kgWcouIx4pMJBiPupQicIwkqfWwCt71PF58Yx6GoCuFHORsemU9/K7afg1kB uWTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711648895; x=1712253695; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LKP3205VA/krnlqaXK8L87jAKCgTJwOgCX0cGrXg7Gk=; b=QK8z57xU4kvZuOJr23Sy7b2yesQtEFRIqgqg1/qo6fu1QJ8kIfMsF14AYnJcJKoaFZ vZ1pR71GqZhkiy59/2AEEKuFoqmrlFQthRnDqfru02WLfx+ipjgshJnBMl+8XsHsZTo/ MkCAjpD7cSuNZ/DYb3NcIARWuqgAiCHV9D7dBOZB4pGi+jgyN6Z8YAf6RFqb8g601hFU Ml17OarB1ngWnzLp0GhfhvZcZPdJGUXf+Dz8AijktpQjkMYD1bw3AxW/aN0MhMvm7LHP 5l28hWoBdJ45iq6XBpzJTo2kqBpbaQV4gVUo+GM3iBat5E9Cmfs2sTXQvJA3DlMdHotL 5NhQ== X-Forwarded-Encrypted: i=1; AJvYcCWiA6Moi89D2UlXXOvJ8IBp2BkW9sQVaaF61KQ3cxzvbekbPdOnJLcG/ZZ7VN4oMxEW8y95FrhULG+NK/T9147s4cLrHFS3TVp4xxt+ X-Gm-Message-State: AOJu0Yy0hsmQPPb77rPR/WLjxUQEclRYnKA4RCV/svhrHDkrpPxBd0fj SFIiD+H6ho6tBYDux+b05rLOemuCl6MzsbVFw4eeMZcWYCrqBEjoG9INQMDP9Q== X-Google-Smtp-Source: AGHT+IGpMnECr7CQUbYG3q+wZef+287ZBjXrkTDJpmqC0WngC8Dgk+UYFTDLQSemG+mXx1Sz2MlyEA== X-Received: by 2002:a05:6512:6c6:b0:515:a9d5:aab6 with SMTP id u6-20020a05651206c600b00515a9d5aab6mr179777lff.18.1711648895114; Thu, 28 Mar 2024 11:01:35 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id rv4-20020a17090710c400b00a46cffe6d06sm1007767ejb.42.2024.03.28.11.01.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Mar 2024 11:01:34 -0700 (PDT) Message-ID: <5091e4a5-472b-430c-a5af-aa74284567c1@enterprisedb.com> Date: Thu, 28 Mar 2024 19:01:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BitmapHeapScan streaming read user and prelim refactoring Content-Language: en-US To: Thomas Munro , Melanie Plageman Cc: Heikki Linnakangas , Andres Freund , Pg Hackers , Nazir Bilal Yavuz References: <5a172d1e-d69c-409a-b1fa-6521214c81c2@iki.fi> <20240323002211.on5vb5ulk6lsdb2u@liskov> <20240323002607.abegehmmjyxrnmm2@liskov> <20240324173833.rdtw42aur2q5hhb2@liskov> <58fa8dd3-a49b-4774-a9c4-7422ba8bc698@enterprisedb.com> <358c737e-772c-40dd-9ecf-35b0c05828cd@enterprisedb.com> <20240325160709.qjo6txzu6zjxzkqy@liskov> <20240327193750.3mlcmzqondpj27xe@liskov> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/28/24 06:20, Thomas Munro wrote: > With the unexplained but apparently somewhat systematic regression > patterns on certain tests and settings, I wonder if they might be due > to read_stream.c trying to form larger reads, making it a bit lazier. > It tries to see what the next block will be before issuing the > fadvise. I think that means that with small I/O concurrency settings, > there might be contrived access patterns where it loses, and needs > effective_io_concurrency to be set one notch higher to keep up, or > something like that. Yes, I think we've speculated this might be the root cause before, but IIRC we didn't manage to verify it actually is the problem. FWIW I don't think the tests use synthetic data, but I don't think it's particularly contrived. > One way to test that idea would be to run the > tests with io_combine_limit = 1 (meaning 1 block). It issues advise > eagerly when io_combine_limit is reached, so I suppose it should be > exactly as eager as master. The only difference then should be that > it automatically suppresses sequential fadvise calls. Sure, I'll give that a try. What are some good values to test? Perhaps 32 and 1, i.e. the default and "no coalescing"? If this turns out to be the problem, does that mean we would consider using a more conservative default value? Is there some "auto tuning" we could do? For example, could we reduce the value combine limit if we start not finding buffers in memory, or something like that? I recognize this may not be possible with buffered I/O, due to not having any insight into page cache. And maybe it's misguided anyway, because how would we know if the right response is to increase or reduce the combine limit? Anyway, doesn't the combine limit work against the idea that effective_io_concurrency is "prefetch distance"? With eic=32 I'd expect we issue prefetch 32 pages ahead, i.e. if we prefetch page X, we should then process 32 pages before we actually need X (and we expect the page to already be in memory, thanks to the gap). But with the combine limit set to 32, is this still true? I've tried going through read_stream_* to determine how this will behave, but read_stream_look_ahead/read_stream_start_pending_read does not make this very clear. I'll have to experiment with some tracing. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company