freebsd 6x slower than Raspbian 10 buster on RPi 4b

Elwood Downey elwood.downey at gmail.com
Mon Feb 8 20:12:50 UTC 2021


Hello all!

Just wanted to share a comparison I did between freebsd and raspbian on the
same RPi 4b with 1 GB RAM. I wrote a tiny C++ program that creates
pthreads, each of which mallocs an array and spins filling it with sqrtf of
the array index. Setting it to 3 threads (the hw has 4 cores), I found
freebsd takes consistently 6.5x wall-clock time longer than with raspbian.
Below are the sessions for each showing pertinent details. Attached is the
program itself (if it doesn't make it through the newsgroup, mail me direct
for a copy). One good news is the thread overhead for freebsd is about 100x
smaller so kudos to the scheduler.

This is surprising and disappointing. Any comments welcome, especially what
I'm doing wrong here. Thank you for your time.

Elwood Downey
Tucson AZ



*Raspbian:*

pi at hamclock:~$ uname -a
Linux hamclock 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l
GNU/Linux
pi at hamclock:~$ g++ --version
g++ (Raspbian 8.3.0-6+rpi1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
pi at hamclock:~$ g++ -Wall -o pthread_bench{,.cpp} -lpthread -lm
pi at hamclock:~$ ./pthread_bench 10000 3
tot thr :   4.917360
mean thr:   1.639120
tot wall:   1.726206
thr gain:   2.84865
overhead:   5.04494 %


*Freebsd:*

[ecdowney at freebsdpi ~]$ uname -a
FreeBSD freebsdpi 13.0-CURRENT FreeBSD 13.0-CURRENT #0
main-c255641-gf2b794e1e90: Thu Jan  7 08:00:13 UTC 2021
root at releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC
 arm64
[ecdowney at freebsdpi ~]$ g++ --version
g++ (FreeBSD Ports Collection) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[ecdowney at freebsdpi ~]$ g++ -Wall -o pthread_bench{,.cpp} -lpthread -lm
[ecdowney at freebsdpi ~]$ sysctl dev.cpu.0.freq
dev.cpu.0.freq: 1500
[ecdowney at freebsdpi ~]$ ./pthread_bench 10000 3
tot thr :  33.810808
mean thr:  11.270269
tot wall:  11.277030
thr gain:    2.9982
overhead: 0.0599537 %
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread_bench.cpp
Type: application/octet-stream
Size: 2141 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20210208/48ebdd4f/attachment.obj>


More information about the freebsd-arm mailing list