From nobody Mon Feb 13 12:51:30 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 4PFkjw0LS3z3qV5Y for ; Mon, 13 Feb 2023 12:51:32 +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 4PFkjv72Kpz41YS for ; Mon, 13 Feb 2023 12:51:31 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676292692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c50IxGRx3YGk2RH931HDATYl34oWuXdyQ45TLmwJE0w=; b=aJz4umMzG3zTqpZs8iZibVSDSQyvtukh1I1FqIzb8vfecu7LpX7Q2GpAxOi8sRVcmUoXeY bxcvX8owhlIC6bqJ3BIfBs2xKHnG/Dsi8vbpkleEqJmzQRM6jgy9Ifv+r+7L5t1N9Xalci ZdvXcLrHPLkZhXA++4DmDi3M+dqhsBOXiJD0VNVilfq8cS+ID9BCuNCJdXQs/Afvz09h7d XNtKpuYRvos8/c+cm16sxtpS/D8QXUITDykDuUtRNmaPHcDfKgiyssPXPEdMclqtKNYs9K LgHvfJNzUCNUZzqOMUdxnGZBI63APtpkjpbrYxbAyyJmmW5Te8Z0qeRtmc4w5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676292692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c50IxGRx3YGk2RH931HDATYl34oWuXdyQ45TLmwJE0w=; b=XWTwUeRFzwfRTUHONHpsWmi4ZuW2r8hfetwbywwT+/uUKnflBfTpxw6p6aSMD8gEMdGpcF Pxtm8cFDZkZS1wqqulUS4Cqbv48Mu0VioUfGWBhp031BsK8weYgTiTLUS9bW852ghH9drL yRtFGiJwaPdFn0GmyvumJlfUZlRBsorYRlwDixdu2Lyr1/aIK/PczS/BE8Cci4KXs4snYT JQd87v7vjtYOj+3wLJnw/m092RDbmqQq+3PXOwDrdJ02cbBFgXy3GC376cLmyv+hZDpY/a Te3D43OyLRZBjqrELhoJhrTYfuE9PhFPtmm4PbG6dOLBTIsXoYLgV6UvOJOk2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676292692; a=rsa-sha256; cv=none; b=vVVgPyGfatGT0hJU6lcVCEwsXoKivWoDc1m8fRiaOP9jEdtSPDCl1PRKhBH3pS79XCYrnz k7HPBawsSPAusd+ALsyneSc6TReetddB6U2SAD2W5jgXPSOzB19aa4lLO9qWGxK7qoyja4 Ub9KOR7+HHLGhmSZVAHt7vF6pBen08/NjtXs/Hp/TYuULN99VzvRvbBvZfWE3wlyULAlUg bEcNWhyfBpBnL59+P2vvj6C7+Tfj9/KBWst9QlmVnbhjYY11E8q5mfhnqaf6qekdBB0gZQ H75VackpyBOJUuvRReMRZj6U5O3I2qv+kJRVRYqvpATACdUqudSrR8fzthbPjw== 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 4PFkjv64mBz1BfZ for ; Mon, 13 Feb 2023 12:51:31 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from [10.164.186.150] (unknown [167.220.197.150]) by smtp.theravensnest.org (Postfix) with ESMTPSA id 7DC1710612 for ; Mon, 13 Feb 2023 12:51:31 +0000 (GMT) Message-ID: Date: Mon, 13 Feb 2023 12:51:30 +0000 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 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: CFT: snmalloc as libc malloc Content-Language: en-GB To: freebsd-hackers@freebsd.org References: <2f3dcda0-5135-290a-2dff-683b2e9fe271@FreeBSD.org> From: David Chisnall In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N On 09/02/2023 23:09, Konstantin Belousov wrote: > On Thu, Feb 09, 2023 at 09:53:34PM +0100, Mateusz Guzik wrote: >> So, as someone who worked on memcpy previously, I note the variant >> currently implemented in libc is pessimal for sizes > 16 bytes because >> it does not use SIMD. I do have plans to rectify that, but ENOTIME. > > Note that you need two kinds of micro-benchmarks for this: > - normal microbenchmark which does the SIMD-enabled memcpy() in a loop > - a microbenchmark which ensures that the SIMD register file ownership > is re-taken on each iteration (or close to it). > > I am sure that the results from #2 would be astonishing and give quite > different prospective on the use of SIMD for basic libc services. Does FreeBSD still do lazy context switching of SIMD state? I was under the impression that this was disabled by all operating systems now because it exposes speculative side channels across a process boundary. Given that the x86-64 and AArch64 ABIs both pass floating point arguments in SIMD registers by default, I'd be surprised if it gave a performance win - unless a workload manages to avoid passing any floating-point arguments in a quantum, it will hit the trap every time. In addition, unless you explicitly disable it, recent versions of clang will use SIMD registers for inlined memcpy (irrespective of what libc does) and will also now spill GPRs to SIMD registers in preference to the stack in some situations. David