NetBSD Problem Report #59789
From www@netbsd.org Mon Nov 24 14:27:04 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(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
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 0AA4D1A9239
for <gnats-bugs@gnats.NetBSD.org>; Mon, 24 Nov 2025 14:27:04 +0000 (UTC)
Message-Id: <20251124142702.C0C761A923A@mollari.NetBSD.org>
Date: Mon, 24 Nov 2025 14:27:02 +0000 (UTC)
From: nia@pkgsrc.org
Reply-To: nia@pkgsrc.org
To: gnats-bugs@NetBSD.org
Subject: bswap is slow
X-Send-Pr-Version: www-1.0
>Number: 59789
>Category: port-sparc64
>Synopsis: bswap is slow
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-sparc64-maintainer
>State: needs-pullups
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Nov 24 14:30:00 +0000 2025
>Closed-Date:
>Last-Modified: Fri Dec 05 13:05:01 +0000 2025
>Originator: nia
>Release: netbsd-11, netbsd-10, netbsd-9...
>Organization:
The NetBSD SPARCstation
>Environment:
NetBSD lilac 11.99.4 NetBSD 11.99.4 (LILAC) #2: Mon Nov 24 14:15:27 CET 2025 nia@siphon:/encrypt/obj/sys/arch/sparc64/compile/LILAC sparc64
>Description:
bswapX on sparc64, unlike other NetBSD ports, does not generate inline
code but rather function calls. This results in some code being
unexpectedly slower than usual, see this mailing list post
for details:
https://mail-index.netbsd.org/port-sparc64/2025/11/24/msg003436.html
>How-To-Repeat:
Disk encryption with adiantum on a sparc64 machine gains 1 MiB/s
speed when function calls are avoided.
>Fix:
One solution is to reuse the existing inline macros on sparc64,
see the patch in the linked mailing list post.
>Release-Note:
>Audit-Trail:
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: src/sys
Date: Wed, 26 Nov 2025 22:25:11 +0000
Module Name: src
Committed By: nia
Date: Wed Nov 26 22:25:11 UTC 2025
Modified Files:
src/sys/arch/sparc/include: bswap.h
src/sys/arch/sparc64/include: bswap.h
src/sys/sys: bswap.h endian.h
Log Message:
sparc: Avoid using GCC builtins for byte-swapping and endian encoding.
gcc on most netbsd architectures (mostly excluding sparc and vax) can
generate fast MD byte-swapping code. On sparc it generates a function
call, which is very slow. We have existing inline macros for byte
swapping, so use those instead.
bswap on sparc with gcc is still non-ideal, so also reactivate the
portable endian encoding functions we apparently haven't been using
since the gcc2 days, rather than using bswap for that.
These changes improve the speed of disk encryption on ultrasparc ii
by almost 40% (the endian.h change being more significant in making
that number go high).
clang does the right thing on sparc (or at least introduces different
bottlenecks...), so avoid this there.
Thanks joerg for analysis of the problem, uwe for reviewing the patch.
PR port-sparc64/59789 bswap is slow
PR kern/59774 bearssl 32-bit AES is too slow
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/include/bswap.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/include/bswap.h
cvs rdiff -u -r1.19 -r1.20 src/sys/sys/bswap.h
cvs rdiff -u -r1.37 -r1.38 src/sys/sys/endian.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->needs-pullups
State-Changed-By: nia@NetBSD.org
State-Changed-When: Fri, 28 Nov 2025 10:49:45 +0000
State-Changed-Why:
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: [netbsd-11] src/sys
Date: Fri, 28 Nov 2025 10:58:02 +0000
Module Name: src
Committed By: martin
Date: Fri Nov 28 10:58:02 UTC 2025
Modified Files:
src/sys/arch/sparc/include [netbsd-11]: bswap.h
src/sys/arch/sparc64/include [netbsd-11]: bswap.h
src/sys/sys [netbsd-11]: bswap.h endian.h
Log Message:
Pull up following revision(s) (requested by nia in ticket #108):
sys/arch/sparc64/include/bswap.h: revision 1.3
sys/arch/sparc/include/bswap.h: revision 1.3
sys/sys/bswap.h: revision 1.20
sys/sys/endian.h: revision 1.38
sparc: Avoid using GCC builtins for byte-swapping and endian encoding.
gcc on most netbsd architectures (mostly excluding sparc and vax) can
generate fast MD byte-swapping code. On sparc it generates a function
call, which is very slow. We have existing inline macros for byte
swapping, so use those instead.
bswap on sparc with gcc is still non-ideal, so also reactivate the
portable endian encoding functions we apparently haven't been using
since the gcc2 days, rather than using bswap for that.
These changes improve the speed of disk encryption on ultrasparc ii
by almost 40% (the endian.h change being more significant in making
that number go high).
clang does the right thing on sparc (or at least introduces different
bottlenecks...), so avoid this there.
Thanks joerg for analysis of the problem, uwe for reviewing the patch.
PR port-sparc64/59789 bswap is slow
PR kern/59774 bearssl 32-bit AES is too slow
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.264.1 src/sys/arch/sparc/include/bswap.h
cvs rdiff -u -r1.2 -r1.2.264.1 src/sys/arch/sparc64/include/bswap.h
cvs rdiff -u -r1.19 -r1.19.56.1 src/sys/sys/bswap.h
cvs rdiff -u -r1.37 -r1.37.2.1 src/sys/sys/endian.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: src/sys/sys
Date: Sat, 29 Nov 2025 15:53:03 +0000
Module Name: src
Committed By: riastradh
Date: Sat Nov 29 15:53:02 UTC 2025
Modified Files:
src/sys/sys: bswap.h
Log Message:
sys/bswap.h: KNF
PR port-sparc64/59789 bswap is slow
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/sys/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: src/sys/arch/mips/include
Date: Sun, 30 Nov 2025 17:43:04 +0000
Module Name: src
Committed By: nia
Date: Sun Nov 30 17:43:04 UTC 2025
Modified Files:
src/sys/arch/mips/include: bswap.h
Log Message:
mips: Use the inline macro version of bswap.
mips suffers from the same problem as sparc where bswap is slow
and using the GCC builtin does not make it better.
This change improves the speed of disk encryption by around 3 MiB/s
on an EdgeRouter 4.
PR port-sparc64/59789
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/include/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: src/sys/arch/powerpc/include
Date: Sun, 30 Nov 2025 17:48:16 +0000
Module Name: src
Committed By: nia
Date: Sun Nov 30 17:48:16 UTC 2025
Modified Files:
src/sys/arch/powerpc/include: bswap.h
Log Message:
powerpc: Use GCC builtins for bswap.
This doubled disk encryption performance on an (emulated) G4. Further
improvements are possible if the GCC 2 version of the endian functions
is used, so we might want to consider doing that on more NetBSD ports.
PR port-sparc64/59789 bswap is slow
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/include/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: src/sys/arch
Date: Tue, 2 Dec 2025 15:40:19 +0000
Module Name: src
Committed By: nia
Date: Tue Dec 2 15:40:19 UTC 2025
Modified Files:
src/sys/arch/sparc/include: bswap.h
src/sys/arch/sparc64/include: bswap.h
Log Message:
We can use __builtin_bswapX on sparc when using clang, so do so.
PR port-sparc64/59789 bswap is slow
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc/include/bswap.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/include/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/59789 CVS commit: [netbsd-11] src/sys/arch
Date: Fri, 5 Dec 2025 13:03:52 +0000
Module Name: src
Committed By: martin
Date: Fri Dec 5 13:03:52 UTC 2025
Modified Files:
src/sys/arch/mips/include [netbsd-11]: bswap.h
src/sys/arch/powerpc/include [netbsd-11]: bswap.h
Log Message:
Pull up following revision(s) (requested by nia in ticket #113):
sys/arch/mips/include/bswap.h: revision 1.6
sys/arch/powerpc/include/bswap.h: revision 1.7
mips: Use the inline macro version of bswap.
mips suffers from the same problem as sparc where bswap is slow
and using the GCC builtin does not make it better.
This change improves the speed of disk encryption by around 3 MiB/s
on an EdgeRouter 4.
PR port-sparc64/59789
powerpc: Use GCC builtins for bswap.
This doubled disk encryption performance on an (emulated) G4. Further
improvements are possible if the GCC 2 version of the endian functions
is used, so we might want to consider doing that on more NetBSD ports.
PR port-sparc64/59789 bswap is slow
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.28.1 src/sys/arch/mips/include/bswap.h
cvs rdiff -u -r1.6 -r1.6.202.1 src/sys/arch/powerpc/include/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.