diff mbox series

wireguard-tools: allow compiling with MIPS16 instructions

Message ID 20200724080254.8389-1-rsalvaterra@gmail.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series wireguard-tools: allow compiling with MIPS16 instructions | expand

Commit Message

Rui Salvaterra July 24, 2020, 8:02 a.m. UTC
The wg utility compiles and runs without issues in MIPS16 mode, despite setting
PKG_USE_MIPS16:=0 in the makefile. Let's remove this, allowing for a substantial
size reduction of the wg executable. Since wg is a just a configuration utility,
it shouldn't be performance-critical, as the crypto heavy-lifting is done on the
kernel side.

wg sizes for both modes:

MIPS32: 64309 bytes
MIPS16: 42501 bytes

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
---
 package/network/utils/wireguard-tools/Makefile | 1 -
 1 file changed, 1 deletion(-)

Comments

Jason A. Donenfeld July 24, 2020, 8:12 a.m. UTC | #1
On Fri, Jul 24, 2020 at 10:03 AM Rui Salvaterra <rsalvaterra@gmail.com> wrote:
>
> The wg utility compiles and runs without issues in MIPS16 mode, despite setting
> PKG_USE_MIPS16:=0 in the makefile. Let's remove this, allowing for a substantial
> size reduction of the wg executable. Since wg is a just a configuration utility,
> it shouldn't be performance-critical, as the crypto heavy-lifting is done on the
> kernel side.
>
> wg sizes for both modes:
>
> MIPS32: 64309 bytes
> MIPS16: 42501 bytes

Seems probably fine to me, but would you let me know if the
performance of `wg pubkey` suffers as a result? I'm far from home at
the moment without any access to MIPS hardware to test myself.

Jason
Rosen Penev July 24, 2020, 8:32 a.m. UTC | #2
> On Jul 24, 2020, at 1:14 AM, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> 
> On Fri, Jul 24, 2020 at 10:03 AM Rui Salvaterra <rsalvaterra@gmail.com> wrote:
>> 
>> The wg utility compiles and runs without issues in MIPS16 mode, despite setting
>> PKG_USE_MIPS16:=0 in the makefile. Let's remove this, allowing for a substantial
>> size reduction of the wg executable. Since wg is a just a configuration utility,
>> it shouldn't be performance-critical, as the crypto heavy-lifting is done on the
>> kernel side.
>> 
>> wg sizes for both modes:
>> 
>> MIPS32: 64309 bytes
>> MIPS16: 42501 bytes
> 
> Seems probably fine to me, but would you let me know if the
> performance of `wg pubkey` suffers as a result?
Of course. I imagine it’s very tiny. Logging in to the router with ssh is much slower.
> I'm far from home at
> the moment without any access to MIPS hardware to test myself.
> 
> Jason
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Rui Salvaterra July 24, 2020, 8:39 a.m. UTC | #3
Well…

On Fri, 24 Jul 2020 at 09:32, Rosen Penev <rosenp@gmail.com> wrote:
>
> > On Jul 24, 2020, at 1:14 AM, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> >
> > Seems probably fine to me, but would you let me know if the
> > performance of `wg pubkey` suffers as a result?
> Of course. I imagine it’s very tiny. Logging in to the router with ssh is much slower.

root@heimdal:/tmp# time wg genkey | tee privatekey | wg pubkey > publickey
real    0m 0.00s
user    0m 0.00s
sys    0m 0.00s
root@heimdal:/tmp#

 … yeah, I don't think performance will be an issue. :)
(This is a 775 MHz 74Kc router, mind you.)

Thanks,
Rui
Jason A. Donenfeld July 24, 2020, 8:53 a.m. UTC | #4
On Fri, Jul 24, 2020 at 10:39 AM Rui Salvaterra <rsalvaterra@gmail.com> wrote:
>
> Well…
>
> On Fri, 24 Jul 2020 at 09:32, Rosen Penev <rosenp@gmail.com> wrote:
> >
> > > On Jul 24, 2020, at 1:14 AM, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> > >
> > > Seems probably fine to me, but would you let me know if the
> > > performance of `wg pubkey` suffers as a result?
> > Of course. I imagine it’s very tiny. Logging in to the router with ssh is much slower.
>
> root@heimdal:/tmp# time wg genkey | tee privatekey | wg pubkey > publickey
> real    0m 0.00s
> user    0m 0.00s
> sys    0m 0.00s
> root@heimdal:/tmp#
>
>  … yeah, I don't think performance will be an issue. :)
> (This is a 775 MHz 74Kc router, mind you.)
>
> Thanks,
> Rui

Testing the process once like that isn't a good testing methodology
representative of anything at all.
Rui Salvaterra July 24, 2020, 9:05 a.m. UTC | #5
On Fri, 24 Jul 2020 at 09:53, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> Testing the process once like that isn't a good testing methodology
> representative of anything at all.

I completely agree, this wasn't an objective test at all. I was merely
illustrating what a normal user will do, generate a key pair to
configure a VPN. If it took more than two seconds, I'd be worried, but
it "feels" instantaneous. I could, of course, time 1000 key
generations in a loop, on a completely idle system, but that wouldn't
represent the typical use case. :)
Jason A. Donenfeld July 24, 2020, 9:11 a.m. UTC | #6
On Fri, Jul 24, 2020 at 11:05 AM Rui Salvaterra <rsalvaterra@gmail.com> wrote:
>
> On Fri, 24 Jul 2020 at 09:53, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> >
> > Testing the process once like that isn't a good testing methodology
> > representative of anything at all.
>
> I completely agree, this wasn't an objective test at all. I was merely
> illustrating what a normal user will do, generate a key pair to
> configure a VPN. If it took more than two seconds, I'd be worried, but
> it "feels" instantaneous. I could, of course, time 1000 key
> generations in a loop, on a completely idle system, but that wouldn't
> represent the typical use case. :)

This might be a typical use case for you, but some people are running
scripts that generate lots of keys. There may be a good argument that
if you're doing that kind of thing, a tiny MIPS router isn't the right
hardware for your use case. But, before going down that route, I'd
still be interested in knowing if it _actually_ makes any difference
at all. Maybe it's negligible, for example.
Rui Salvaterra July 24, 2020, 10:17 a.m. UTC | #7
Hi again, Jason,

On Fri, 24 Jul 2020 at 10:12, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> This might be a typical use case for you, but some people are running
> scripts that generate lots of keys. There may be a good argument that
> if you're doing that kind of thing, a tiny MIPS router isn't the right
> hardware for your use case. But, before going down that route, I'd
> still be interested in knowing if it _actually_ makes any difference
> at all. Maybe it's negligible, for example.

Here are more objective numbers. I timed 1000 runs of wg genkey | wg
pubkey > /dev/null. Each timing was done four times for both MIPS16
and MIPS32 and the worst results were chosen.

MIPS32 results:
real    0m 10.06s
user    0m 8.12s
sys    0m 1.34s

MIPS16 results:
real    0m 11.96s
user    0m 10.14s
sys    0m 1.15s

I'd say the difference is, indeed, negligible.

Thanks,
Rui
diff mbox series

Patch

diff --git a/package/network/utils/wireguard-tools/Makefile b/package/network/utils/wireguard-tools/Makefile
index 3232060bd1..2137a8b4a1 100644
--- a/package/network/utils/wireguard-tools/Makefile
+++ b/package/network/utils/wireguard-tools/Makefile
@@ -22,7 +22,6 @@  PKG_LICENSE:=GPL-2.0
 PKG_LICENSE_FILES:=COPYING
 
 PKG_BUILD_PARALLEL:=1
-PKG_USE_MIPS16:=0
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/package-defaults.mk