From nobody Thu Feb 09 19:36:48 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PCRvR4CPtz3nTlP for ; Thu, 9 Feb 2023 19:36:51 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PCRvR3gPqz3mBw; Thu, 9 Feb 2023 19:36:51 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675971411; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZMst3TDKpRdZkQ8z3KR3QzMYccqCX00YrRdDckSxE4Y=; b=AT4unnoDFGjpUoMNdirBBoWAXXfvXqPC4VGgWVFJ1BvZU5O6R45cW4/0nXQYpVIWWlyg+n YNfNoPBrlKma0QfHdOrlzdcl2Vy6/mmtPkx9th8mjzstAOoKb+qE9UcPZChvtFtHFBQLHf 1qD3tSJEOEZb2VvMDI2RtEi7U4ENWOCmvA/rHZACbSlodHOS34h04QlUVQxvHzLwRRHJji kn+WrPfyZEhwqfJYmaDMTPsEGgufiJOSE7KzOpw8rXMtDeOGvOJj3I1L99uBFZhy2MY72q HgSEJUV3Ba/rZsUk6epzS42BAp2uhBBi+DNLnCq9Ki3LQr8R0XeIhU0j7zhA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675971411; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZMst3TDKpRdZkQ8z3KR3QzMYccqCX00YrRdDckSxE4Y=; b=j15biPAbB23orzbcc84aPZpCfFpNGbq6aICWu8BxiHqYR0lS4rnC6owEUfzV7zjeCjFQvW PEqX3xYO4G9EUAP2D/telOM1UDMCFHasb04pgQpVWPALiCmgoPIIThDpL3iONFW+tJILhl //K+AoXlnnj7RD9pVNuR8Ya0yy5K2FLIjNhhV4AyaxQIy8kdh2gJxruRFrp4ALcodfvmCh FMiwhT1Fh7mnE5kj4GTZgJcLo91129OwcXIQmioGdTKfbwOZfyba4A8xJC5skLyQryEJI+ Abz6BMRDkgua5vyDlZPQsmf5C3ggfJuJlWWvEBO7aoieUuzwRZNgh+EivDn/fw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675971411; a=rsa-sha256; cv=none; b=b7wTWpbzyMA3N+PJIOB32GUpobWMoEjLMjhT1u10H0Sh0Ri3+2YNXLixGdUJqbsHjg5OhQ Jen4N0Qa+/vk8AeQuCJTzcyfsgbuYGQubQDZGw4MZymZQr1OuH5u9HLn7OVImskqbC5Xyr eylYpb08P9SNArlzdqWKQAG1PhJf7OtrxaQqbW8fpRWcnMefyQvXUsoLmRxDflHtnh78aI A59vzTMnZQNcwcxkqrqRuqeqzvHysTYeLPLrUzJjWiD8EIEQnB9RbL69HVHW++s4A9C/pD YNh7CgGijwbJoVVy7ni/huDfC/uThQLxVA4zEJEr8lUFXSWKt18IvfzwHW2hVw== Received: from smtp.theravensnest.org (smtp.theravensnest.org [45.77.103.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: theraven) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PCRvR2b2NzV8J; Thu, 9 Feb 2023 19:36:51 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtpclient.apple (host81-158-36-31.range81-158.btcentralplus.com [81.158.36.31]) by smtp.theravensnest.org (Postfix) with ESMTPSA id AF3F21058A; Thu, 9 Feb 2023 19:36:49 +0000 (GMT) Content-Type: text/plain; charset=utf-8 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: CFT: snmalloc as libc malloc From: David Chisnall In-Reply-To: Date: Thu, 9 Feb 2023 19:36:48 +0000 Cc: freebsd-hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <2f3dcda0-5135-290a-2dff-683b2e9fe271@FreeBSD.org> To: Mateusz Guzik X-Mailer: Apple Mail (2.3654.120.0.1.13) X-ThisMailContainsUnwantedMimeParts: N On 9 Feb 2023, at 19:15, Mateusz Guzik wrote: >=20 > it fails to build for me: >=20 > /usr/src/lib/libc/stdlib/snmalloc/malloc.cc:35:10: fatal error: > 'override/jemalloc_compat.cc' file not found > #include "override/jemalloc_compat.cc" > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > --- malloc.o --- > *** [malloc.o] Error code 1 >=20 > make[4]: stopped in /usr/src/lib/libc > /usr/src/lib/libc/stdlib/snmalloc/memcpy.cc:25:10: fatal error: > 'global/memcpy.h' file not found > #include > ^~~~~~~~~~~~~~~~~ > 1 error generated. > --- memcpy.o --- > *** [memcpy.o] Error code 1 This looks as if you haven=E2=80=99t got the submodule? Is there = anything in contrib/snmalloc? > this is a fresh world, top of snmalloc2 branch: > commit a5c83c69817d03943b8be982dd815c7e263d1a83 > Author: David Chisnall > Date: Fri Jan 21 15:13:09 2022 +0000 >=20 > Initial commit of snmalloc2 in libc. >=20 > anyway, I wanted to say I find the memcpy thing incredibly suspicious. > I found one article in > = https://github.com/microsoft/snmalloc/blob/main/docs/security/GuardedMemcp= y.md > which benches it and that made it even more suspicious. How did the > benched memcpy look like inside? Perhaps you could share what you are suspicious about? I don=E2=80=99t = really know how to respond to something so vague. The document you = linked to has the benchmark that we used (though the graphs in it appear = to be based on an older version of the memcpy). The PR that added = PowerPC tuning has some additional graphs of measurements. If you compile the memcpy file, you can see the assembly. The C++ = provides a set of building blocks for producing efficient memcpy = implementations. The fastest on x86 is roughly: - A jump table of power for small sizes that do power-of-two-sized = small copies (double-word, word, half-word, and byte) to perform the = copy. - A vectorised copy for medium-sized copies using a loop of SSE copies. - rep movsb for large copies. The compiler does some quite complex layout for the jump table. David