From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1806 invoked from network); 20 Sep 2022 17:49:39 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Sep 2022 17:49:39 -0000 Received: (qmail 9996 invoked by uid 550); 20 Sep 2022 17:49:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7455 invoked from network); 20 Sep 2022 17:45:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663695938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vKuBVt6uDvvtHOvgLROeNDyGZW53OOwyMcGDDWsd/Bc=; b=hXIq5ETnEVOE5iV7RAZD86CfDT+gnNRYRVuzRtpQLcFRjYxZ8dEbOgXO/chlNS/z/++0IN +TiibBYwQQqtvy5sUdX2bc22UGDTVJ2rWGb+5sDJrp/jKEnLT33iOrA833xo8tiU/Tv/8X fL2In8LtE9QnqsFF1t2LsVI83nfq7zU= X-MC-Unique: YvFH3YmHOViN_v_iag2zJw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=vKuBVt6uDvvtHOvgLROeNDyGZW53OOwyMcGDDWsd/Bc=; b=s70Lb6822rGivrapVZef7fTYtzffCdvso43AQgSkv1q4JrCBSf4ZvaN+zBgCLlsk7D PaiNMbAFbnlPOmQY066NY8btCjA01/FJ3U9qoVPhhrEyM7PbmNtA+7IQNBP9PmkU+ME8 bAWCHTAy4Ykwsse+Rr+MoqqPuu5M+xpVQwnVLqUxV5aXqPrIZG3RQXEhVeF559HNrENJ sVXtDqlVKPia/W8Znakk+vCJeYhP+vnOlJe7czKYz4oTjFh5mmQSGC16cXJHpOfot2K5 oyodKkajzncBB6083/mWWZdzmk4EwhNeDYf3q7RrYnvev0cVf45Z599AJPAF5eEpQHdn KkzQ== X-Gm-Message-State: ACrzQf3HNp+P4EQnkIP4V7sJtRm6v14TPAcWVShtzHLrYmjBMzEAygaO vjFsDXOFd3BXMf5g5Zf6PmxLVuPk8wyTWcKEyt8AzdfsfWUKUmFd+HXCL//eQ6TsXTZWlaBmSW9 NWxbXctWil3QHVmabv5jYHtyR3x0jry5tkA== X-Received: by 2002:a17:907:1c08:b0:77c:8d2:bb9 with SMTP id nc8-20020a1709071c0800b0077c08d20bb9mr17550406ejc.177.1663695933615; Tue, 20 Sep 2022 10:45:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pe632ZsqMkSpg4oMCEAljE+ZjvbUuhT8aqcE+Tdcn8pwO7b3PxHBvD0Ugu7D9/epQuI9hJPoW0MT8qIHabKs= X-Received: by 2002:a17:907:1c08:b0:77c:8d2:bb9 with SMTP id nc8-20020a1709071c0800b0077c08d20bb9mr17550396ejc.177.1663695933418; Tue, 20 Sep 2022 10:45:33 -0700 (PDT) MIME-Version: 1.0 References: <2022091915532777412615@gmail.com> <20220919110829.GA2158779@port70.net> <874jx3h76u.fsf@oldenburg.str.redhat.com> <20220919134659.GO9709@brightrain.aerifal.cx> <874jx2phqm.fsf@oldenburg.str.redhat.com> <202209210128529625329@gmail.com> In-Reply-To: <202209210128529625329@gmail.com> From: Siddhesh Poyarekar Date: Tue, 20 Sep 2022 13:44:56 -0400 Message-ID: To: baiyang Cc: Florian Weimer , Rich Felker , musl X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: Re: [musl] The heap memory performance (malloc/free/realloc) is significantly degraded in musl 1.2 (compared to 1.1) On Tue, Sep 20, 2022 at 1:28 PM baiyang wrote: > > > Is there any other valid reason to use > > malloc_usable_size instead of simply using realloc? > > Yes, we use it as one of the parameters to estimate the memory copy cost when realloc degenerates back to malloc+memcpy+free, refer to the previous mails. I was only pulled into this conversation with the email I responded to; I am not subscribed to the musl mailing list. If this estimation is not for diagnostics then it's really not that different from the case I'm talking about. You shouldn't have to do this check and realloc should do the right thing whenever there's space available in the chunk. I can't comment on musl-specific bits because I haven't taken a close enough look at mallocng to do that. In general though, I don't think it makes sense for a C library to support malloc_usable_size beyond diagnostics. Sid