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 1rb76Y-00DNVJ-TX for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 22:54:51 +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 1rb76W-005CM2-QK for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 22:54:48 +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 1rb76W-005CLt-F7 for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 22:54:48 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rb76R-0077WN-H7 for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 22:54:46 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33d28998e8bso166751f8f.3 for ; Fri, 16 Feb 2024 14:54:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1708124082; x=1708728882; darn=lists.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=+t8JZEPIUHD2Qq8ra1Ry5ESRPyjIsrNXRObWBhd3XJY=; b=kcOTo0J0vKmmnrGwQc6w9tA2zPArJOcRjGbZUX0M0xaVWCd3P14QngVgAjhLlNp9lD gmaVNh9SvL2PVdqzMD8dOXgTo2OcZrnqfGRa+aP6Y2ac2wcUEYSL+or2D5xFWFZIRyJv wOVxqUbctHCy7MFf7ZXbiP74bsuuyUbrKpxx6Y4TYsht8x6LdqrbMmo0C0S9TDcoBpra YxJ9+1lBzPpP7EKSRWn/K1zbeD537u1Ult0f6yPdEUdYNH+kJY/zSSCDjHwJziuc0+K2 HAr+k1qPZp5pvC0rTqAIn8439zyBtwn5+YdfxLNDu814nw2MV7q/FI+lZX3UZx4H+VDE HuUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708124082; x=1708728882; 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=+t8JZEPIUHD2Qq8ra1Ry5ESRPyjIsrNXRObWBhd3XJY=; b=Ifs0y+OnoZsV57KfAO0CM9oAKy/5513Wg3BDjIkhVmOyvd4yh9Yd1QDm8TLVUIFZng r8IXVMuA5lx1wpel6Mc5VehU4GHKdzhAv1mhDT9hVuH5EmTx2QiWMQZeDT4wBgrHCK/A aolIHxcozkscBJopPeYChuJ2Hwn23ldcumZyC/tDMJQKmukGiJC5AnosgVYXwQaO+pmP HHi09tmJUtYBMhihWbea+hqSBdPyn9dgDQriOpFM4aBk/Rp0I3IvW1DmgPQpUWph3o0r /bHu8SUzBfnkApHmNke6PuAqPnq6p2zSh8f1venpaUyF+106oiqbIQ5s37exjRoxAiik ANvg== X-Gm-Message-State: AOJu0YzSH2HDBZTy175jZfhXo1Lcr4Kiuv/L81Oq1fq61+ZEoV30Qw4k SSvdHs8pL4gxKgQfwdwR/Z74eRlapZoL6NCsQBjxCOzP3yd6o5cQUMHKbZP5/Q== X-Google-Smtp-Source: AGHT+IF8nu1nUR/TdTqd9e6w8EcZVS8m10TYXGApEsWPuFkJLQT51H+0j1iZCXxENhN8BMZUX3KIkg== X-Received: by 2002:a5d:60c8:0:b0:33d:2834:a67c with SMTP id x8-20020a5d60c8000000b0033d2834a67cmr480853wrt.69.1708124081899; Fri, 16 Feb 2024 14:54:41 -0800 (PST) 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 u7-20020a5d6ac7000000b0033d1500b639sm3309948wrw.30.2024.02.16.14.54.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 14:54:41 -0800 (PST) Message-ID: <2d64ebf0-51d9-4dda-b98a-79c21fcf9941@enterprisedb.com> Date: Fri, 16 Feb 2024 23:54:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add bump memory context type and use it for tuplesorts Content-Language: en-US To: Matthias van de Meent , David Rowley Cc: PostgreSQL Developers References: 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 11/6/23 19:54, Matthias van de Meent wrote: > > ... > > Tangent: Do we have specific notes on worst-case memory usage of > memory contexts with various allocation patterns? This new bump > allocator seems to be quite efficient, but in a worst-case allocation > pattern it can still waste about 1/3 of its allocated memory due to > never using free space on previous blocks after an allocation didn't > fit on that block. > It probably isn't going to be a huge problem in general, but this > seems like something that could be documented as a potential problem > when you're looking for which allocator to use and compare it with > other allocators that handle different allocation sizes more > gracefully. > I don't think it's documented anywhere, but I agree it might be an interesting piece of information. It probably did not matter too much when we had just AllocSet, but now we have 3 very different allocators, so maybe we should explain this. When implementing these allocators, it didn't feel that important, because the new allocators started as intended for a very specific part of the code (as in "This piece of code has a very unique allocation pattern, let's develop a custom allocator for it."), but if we feel we want to make it simpler to use the allocators elsewhere ... I think there are two obvious places where to document this - either in the header of each memory context .c file, or a README in the mmgr directory. Or some combination of it. At some point I was thinking about writing a "proper paper" comparing these allocators in a more scientific / thorough way, but I never got to do it. I wonder if that'd be interesting for enough people. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company