| Message ID | cover.1782911956.git.fweimer@redhat.com (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D33DA4BA2E3F for <patchwork@sourceware.org>; Wed, 1 Jul 2026 13:39:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D33DA4BA2E3F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=h/FGw4ud X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 825064BA543C for <libc-alpha@sourceware.org>; Wed, 1 Jul 2026 13:38:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 825064BA543C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 825064BA543C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782913130; cv=none; b=HGW9Tqq58s0baZIShnTm89VfYionG4eArmb+3lXbCIfcKEtAjM2HMwrYTeR8xPJE6dzs5Rj+gVkbfrwo2xcjT0IHGp2GwHCF2CImSMciIou/I/YVFLNdyyRFBnEk0RAuDfrheiSTaDY39WxLcW3ssP7XGsdcrq4rtRCr2xrBfQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782913130; c=relaxed/simple; bh=Np2eHAgP/ZTbO2J8YCJnpOsqvnVsKQE7xDeMSOHa6Ds=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=qmpaXA3cdK+euKQda+x8WbyXNWAKtqmjIQrCd8StEp/0swFwyDkughQa6Aytpw0GrO3J5nONvlHQdRRa8lcfGWSoPUMU29l2+wFfx3U2cPXgL/kNxTulqHjR5g3ny7W3eDC0BgcfhivyW2sQChpA1jwlycFAVMu5ltoVSx3+zF8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=h/FGw4ud DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 825064BA543C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782913130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=P6tzFehTCJaQzDVP+Lf2HWIHrm/Bybw1WZAysfnrNBo=; b=h/FGw4udj84+/YI6KzYOVnFYLENqjYNWix41xSTAxskB2TvOHvRnEB5OqZqjEj+AmDsixw TRd96aAtJ2q+p+q9kpE+kCwoiqwgACCb/A/70NgFQVMTdynWe+n+p7XfkKNzT9MieXKUhN BkPVjcWkP+ge8fSa/sxTxh632ISYGdM= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-b19tu52cNQavbk2Fk0MHeg-1; Wed, 01 Jul 2026 09:38:49 -0400 X-MC-Unique: b19tu52cNQavbk2Fk0MHeg-1 X-Mimecast-MFC-AGG-ID: b19tu52cNQavbk2Fk0MHeg_1782913128 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2714D1808978 for <libc-alpha@sourceware.org>; Wed, 1 Jul 2026 13:38:48 +0000 (UTC) Received: from fweimer-oldenburg.csb.redhat.com (unknown [10.44.32.220]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 58A241955D53 for <libc-alpha@sourceware.org>; Wed, 1 Jul 2026 13:38:47 +0000 (UTC) From: Florian Weimer <fweimer@redhat.com> To: libc-alpha@sourceware.org Subject: [PATCH v2 0/4] malloc: Batched frees, tcache hysteresis behavior Message-ID: <cover.1782911956.git.fweimer@redhat.com> X-From-Line: d02dc1493477fca96d0bec166ef01fbb5602b82c Mon Sep 17 00:00:00 2001 Date: Wed, 01 Jul 2026 15:38:35 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bEJJSVY4lg3C1f6W5W0d6i8jch1K31t8CyT62PJ0Dcw_1782913128 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
malloc: Batched frees, tcache hysteresis behavior
|
|
Message
Florian Weimer
July 1, 2026, 1:38 p.m. UTC
This series implements batched frees. The new addition is the last patch, which avoids repeated unlinking and linking of bins, which is very expensive. Compared to the previous series, this one is actually faster than the non-batched code. I see very small regressions in cfrac and espresso, possibly in the benchmark noise. Other benchmarks are generally on par with a tcache bump to 32 entries (despite using only 16 on average), with some quite signifcant outliers such as bench-malloc-simple/main_arena_mt_allocs_0400_time, which is ~39% faster than mainline (a 32-depth tcache leads only to a ~%4 improvement). The larson application server/remote-free workload is about 7% faster as well. I also tried a deep merge implementation that inlines parts of _int_free_merge_chunk and _int_free_create_chunk into the batched free loop, avoiding even more repeated linking and unlinking. However, that was not generally beneficial, and it is quite a bit of additional code to maintain. However, I only implemented aggressive backwards coalescing, forward coalescing was more limited in multi-threaded mode because it's not possible to check if a chunk is allocated in a race-free manner without taking the arena lock. Another attempt tried to avoid arena lock switching more aggressively, but like sorting, this leads to quadratic work in the number of tcache entries. It was not generally faster than what is posted here, but it's also quite complicated. Thanks, Florian Florian Weimer (4): malloc: Perform batched frees if tcache is full malloc: Only fill half of the tcache during batch allocation malloc: Increase tcache fill count from 16 to 32 malloc: Implement merging of tcache chunks during batched frees malloc/malloc.c | 141 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 130 insertions(+), 11 deletions(-) base-commit: 84c3993f1ff1546c8dd06c3ced5d2bed0be649c0