From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3aRxLf2o+2jxbQYAWB0awg (envelope-from ) for ; Fri, 24 Oct 2025 12:27:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1761323261; bh=1cU+V6OQLFyWIaSHDQ0sRX/Qi+j4/byzHvQbYHVKZZc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n8X3Hrfoh7aNcmbNKoBbJitA6CFBNLKaD78RlsTNAyf/7SZI6cFVpGL32gFBx9sp/ /4YE9M0l4ujp2/3ee7yqGf5oKu94zCT9IBNGH3CTEm/I77Z5Jcwnhh+M15hf7bztra D1RKnHxOa8KU6IcOGkDOr7DUxsR+1m6w1puOWBn0= Received: by simark.ca (Postfix, from userid 112) id A82831E04C; Fri, 24 Oct 2025 12:27:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=SwNqoVSw; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0152A1E04C for ; Fri, 24 Oct 2025 12:27:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 709D6385B532 for ; Fri, 24 Oct 2025 16:27:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 709D6385B532 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=SwNqoVSw Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 8CF8F3857356 for ; Fri, 24 Oct 2025 16:25:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CF8F3857356 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8CF8F3857356 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761323113; cv=none; b=fRT9r4ZMCdIfXQqq1fOOPF2uLM5Fvu2JORSPBxamvDSW6Dcfygo8hVLazFVfnIpKR1VEv1CAbd+M20/arvjWPGTwi5rtpswdDaa/7qZ69QvpwpKJ/WX919m9z8kTcu3PtuscVWF1HpWLIkM0veM64v5dMN+Gz4GR0lbP8Bp2hZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761323113; c=relaxed/simple; bh=1cU+V6OQLFyWIaSHDQ0sRX/Qi+j4/byzHvQbYHVKZZc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rwuMCAEQ0ZgOJVzCHiotGZu1i0fpZUrCWoFfs87Qm6wlh+hAilXoWHBX6izQbWHoRr0wMGx+0iYz8dIbbBA4ic6lGJ+Zi91MgShtYOhc6YZO4RXsRBFiUlvYyk6UxqdRqjHIRC9AiKZf/I4+AVHi1/AfYmH7TZELsuE4Bev9NzI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CF8F3857356 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1761323113; bh=1cU+V6OQLFyWIaSHDQ0sRX/Qi+j4/byzHvQbYHVKZZc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SwNqoVSwKWOHW0aEuc0XEXlfNlm33gPR1TvtFB4ZRVw/W0BhtpNdROVAUv96/QVZY 1kgCLaUnXSEueMH25hUx6QjBSL7+LFoXPRVAvsmTnHTp59shKT6rSFR4qMZpQ1IcIg XEfwDwD0s5DZ0T7Uk9dAArau4RmQtZc80zJHOo6I= Received: by simark.ca (Postfix) id 148331E04C; Fri, 24 Oct 2025 12:25:12 -0400 (EDT) Message-ID: <42123ec4-5b99-410d-bde1-3b506117cea6@simark.ca> Date: Fri, 24 Oct 2025 12:25:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] Free multidicts from blockvector To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20251023-mdict-free-v1-0-ad02b2bdd549@tromey.com> <20251023-mdict-free-v1-2-ad02b2bdd549@tromey.com> <873479bgdf.fsf@tromey.com> <87ecqsie88.fsf@tromey.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87ecqsie88.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/24/25 10:08 AM, Tom Tromey wrote: > Simon> Ideally it would be struct block's just to call that. You could add a > Simon> destructor to struct block and call it explicitly here. It would be the > Simon> same result, but would be more correct encapsulation-wise. But I guess > Simon> this is fine too for the time being. > > Tom> Yeah. I have kind of an aversion to explicit destructor calls. > Tom> Though maybe not for any good reason. > > I was thinking about this last night and realized there's a bigger > issue, which is that blocks are allocated on an obstack: > > struct block : public allocate_on_obstack > > and > > block = new (&m_objfile->objfile_obstack) struct block; > > but allocate_on_obstack requires that the object be trivially > destructible. > > Maybe this could be remedied by resurrecting Jan's obstack allocator; > making an "obstack_ptr" class that explicitly calls the destructor but > not 'delete'; and finally changing blockvector to hold these. I guess that this restriction of "objects allocated on obstack must be trivially destructible" is a bit artificial and arbitrary? It is technically fine to allocate on obstack an object having a destructor, as long as you ensure the destructor is called at some point. I guess the restriction was put because it's easy to forget and error prone. This obstack_ptr you talk about (obstack_unique_ptr?) sounds like a good way to automate it. I was wondering if we needed to keep allocating these on an obstack, but my understanding is that obstack is a good choice here because: - We can't use a vector to store them, since the blocks themselves can't move, as that would break the parent (superblock) relationship - There is a ton of blocks created, so it's nice to be able to free their memory in O(1). Unfortunately, having to free block::m_multidict means that part is O(n), but the less we have to do in O(n) the better I guess? Simon