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 1rb6yG-00DLhl-Tg for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 22:46:16 +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 1rb6yE-0059bO-61 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 22:46:14 +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 1rb6yD-0059bF-SV for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 22:46:13 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rb6y9-0077Sm-3U for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 22:46:11 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41243d19ecaso7578845e9.3 for ; Fri, 16 Feb 2024 14:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1708123566; x=1708728366; 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=JyJwFRNWo0a0cXUdtjQBsfIoYD5d8evdpjGcE4JLiUs=; b=mimbU11IWrxbb1JHdUb82u2E2fRU9ynLOWTCK98vva0Khbf1y+60Yi0T9EzbOFthAZ F8MiRvdOZdvg3GeUmsa7PzjlT0XvYJhnJwUFSKUrMoiweWSyXc+8LI8zZEVlJB+nL4/u vIKWes0P9d8a0ao6Ro06M7TcEKRcjmWnBzxcwOac7canhvgJgMQahT4fuOgmCcVMNMsR bMpYQ2l6eS4dnic00GOVNueN2PjXsbyEVW/3PmCMoyr/gcsVDPIuk3DJ9gbX4VBHNN3o +oDvOsC1rZPgvAIsbCeLNe3wU7p7zFsNo9ayzolbpRgSbFDEU1C/f8u/VCxiuU8+KWBc 4Gwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708123566; x=1708728366; 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=JyJwFRNWo0a0cXUdtjQBsfIoYD5d8evdpjGcE4JLiUs=; b=Hb1n4otVSrmHlMAVXUbvULMmvqY+8vkXsAsGy8PobaoU8CVnIBe6LCNnui5nrIpLX8 lZfJUi6enebVoWoagBaf8WaqT6ZoNtIpMRA5Yx1+YTP20CTqHH3GYAkgPqJXJ1Yrz+eT 1k0BD757XiihrrhCDldjOjB7q4npaYxiiSwP1NOZLhNRfYQnD0jhlR+80YsF0GNc1shJ +ED0MgLmWK4o+OBEap/9tVYp/dxqja82cyLyEw9RWutMdhwqPxNcMw5mwX/ZSEleK28F N2QEeV/IAZLUCmBByjXK0ELp+xze6Yl/xN24g10Qxf1srzlyr4VlIZ6mA5ToOW4PbPWO LdpQ== X-Forwarded-Encrypted: i=1; AJvYcCW6pBUcxPbCGUno6LFhebralx95MiAdxUdWTnr4eyWZe4X6cSGHPo5aKGcgIXLCaieSu47WgdC2JDzpAxN9m5a+mDBkLgMpv8BK6tHhbVkQ2FcP X-Gm-Message-State: AOJu0YxCkBPqfqA33XEDucWGMR+4UXT+zO983J6HmaWmys1x21h1LPwN AH4dflOFf9Pg8PWcvvtOuSuTQNk7wHyMfBk+zWEUzvQK1jzOqnkYjnMcNEOrTQ== X-Google-Smtp-Source: AGHT+IFE0t5DJEyzhCBu36a5uYM06BIq5fHOIkzQ/wbA4Tz+W3U9xj1o3A61OZbsM6xoljN0XFAqCw== X-Received: by 2002:a05:600c:4f0f:b0:410:e830:24 with SMTP id l15-20020a05600c4f0f00b00410e8300024mr5178711wmq.7.1708123564988; Fri, 16 Feb 2024 14:46:04 -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 o20-20020a05600c511400b00410395dc7d1sm3658394wms.7.2024.02.16.14.46.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 14:46:04 -0800 (PST) Message-ID: Date: Fri, 16 Feb 2024 23:46:03 +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 Cc: David Rowley , 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 Hi, I wanted to take a look at this patch but it seems to need a rebase, because of a seemingly trivial conflict in MemoryContextMethodID: --- src/include/utils/memutils_internal.h +++ src/include/utils/memutils_internal.h @@ -123,12 +140,13 @@ typedef enum MemoryContextMethodID { MCTX_UNUSED1_ID, /* 000 occurs in never-used memory */ MCTX_UNUSED2_ID, /* glibc malloc'd chunks usually match 001 */ - MCTX_UNUSED3_ID, /* glibc malloc'd chunks > 128kB match 010 */ + MCTX_BUMP_ID, /* glibc malloc'd chunks > 128kB match 010 + * XXX? */ MCTX_ASET_ID, MCTX_GENERATION_ID, MCTX_SLAB_ID, MCTX_ALIGNED_REDIRECT_ID, - MCTX_UNUSED4_ID /* 111 occurs in wipe_mem'd memory */ + MCTX_UNUSED3_ID /* 111 occurs in wipe_mem'd memory */ } MemoryContextMethodID; I wasn't paying much attention to these memcontext reworks in 2022, so my instinct was simply to use one of those "UNUSED" IDs. But after looking at the 80ef92675823 a bit more, are those IDs really unused? I mean, we're relying on those values to detect bogus pointers, right? So if we instead start using those values for a new memory context, won't we lose the ability to detect those issues? Maybe I'm completely misunderstanding the implication of those limits, but doesn't this mean the claim that we can support 8 memory context types is not quite true, and the limit is 4, because the 4 IDs are already used for malloc stuff? One thing that confuses me a bit is that the comments introduced by 80ef92675823 talk about glibc, but the related discussion in [1] talks a lot about FreeBSD, NetBSD, ... which don't actually use glibc (AFAIK). So how portable are those unused IDs, actually? Or am I just too caffeine-deprived and missing something obvious? regards [1] https://postgr.es/m/2910981.1665080361@sss.pgh.pa.us -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company