Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Feb 2021 13:12:36 -0700
From:      Elwood Downey <elwood.downey@gmail.com>
To:        freebsd-arm@freebsd.org
Subject:   freebsd 6x slower than Raspbian 10 buster on RPi 4b
Message-ID:  <CAL98DL44SPbiT9EHuxrDSzttUyv0coj6nGNJ2VpYArsfujP_bg@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--00000000000029158f05bad8cbec
Content-Type: text/plain; charset="UTF-8"

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@hamclock:~$ uname -a
Linux hamclock 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l
GNU/Linux
pi@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@hamclock:~$ g++ -Wall -o pthread_bench{,.cpp} -lpthread -lm
pi@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@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@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC
 arm64
[ecdowney@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@freebsdpi ~]$ g++ -Wall -o pthread_bench{,.cpp} -lpthread -lm
[ecdowney@freebsdpi ~]$ sysctl dev.cpu.0.freq
dev.cpu.0.freq: 1500
[ecdowney@freebsdpi ~]$ ./pthread_bench 10000 3
tot thr :  33.810808
mean thr:  11.270269
tot wall:  11.277030
thr gain:    2.9982
overhead: 0.0599537 %

--00000000000029158f05bad8cbec
Content-Type: application/octet-stream; name="pthread_bench.cpp"
Content-Disposition: attachment; filename="pthread_bench.cpp"
Content-Transfer-Encoding: base64
Content-ID: <f_kkx0fh6j0>
X-Attachment-Id: f_kkx0fh6j0

Lyogc2ltcGxlIHRocmVhZCBiZW5jaAogKi8KCiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8
c3RkbGliLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPG1hdGguaD4KI2luY2x1ZGUg
PHB0aHJlYWQuaD4KI2luY2x1ZGUgPHN5cy90aW1lLmg+CiNpbmNsdWRlIDxzeXMvcmVzb3VyY2Uu
aD4KCiNkZWZpbmUgRFRVUyh0MSx0MCkgICAgICgodDEudHZfc2VjLXQwLnR2X3NlYykqMTAwMDAw
MEwgKyAodDEudHZfdXNlYy10MC50dl91c2VjKSkKCmludCBuX2xvb3BzOwoKLyogb25lIHRocmVh
ZC4KICovCnZvaWQgKnJ1biAodm9pZCAqZHVtbXkpCnsKICAgICAgICBpbnQgKmYgPSAoaW50ICop
IGNhbGxvYyAobl9sb29wcywgc2l6ZW9mKGludCkpOwogICAgICAgIGlmICghZikgewogICAgICAg
ICAgICBmcHJpbnRmIChzdGRlcnIsICJubyBtYWxsb2NcbiIpOwogICAgICAgICAgICByZXR1cm4o
TlVMTCk7CiAgICAgICAgfQogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbl9sb29wczsgaSsr
KQogICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG5fbG9vcHM7IGorKykKICAgICAgICAg
ICAgICAgIGZbaV0gPSBzcXJ0ZihpKmopOwogICAgICAgIGZyZWUgKGYpOwogICAgICAgIHJldHVy
biAoTlVMTCk7Cn0KCmludCBtYWluIChpbnQgYWMsIGNoYXIgKmF2W10pCnsKICAgICAgICAvLyBw
cmVwCiAgICAgICAgaWYgKGFjICE9IDMpIHsKICAgICAgICAgICAgZnByaW50ZiAoc3RkZXJyLCAi
VXNhZ2U6ICVzIGxvb3BzIHRocmVhZHNcbiIsIGF2WzBdKTsKICAgICAgICAgICAgZXhpdCgxKTsK
ICAgICAgICB9CiAgICAgICAgbl9sb29wcyA9IGF0b2koYXZbMV0pOwogICAgICAgIGludCBuX3Ro
ID0gYXRvaShhdlsyXSk7CiAgICAgICAgcHRocmVhZF90IHRpZFtuX3RoXTsKICAgICAgICBzdHJ1
Y3QgdGltZXZhbCB0MCwgdDE7CiAgICAgICAgaW50IGU7CgogICAgICAgIC8vIHN0YXJ0CiAgICAg
ICAgZ2V0dGltZW9mZGF5ICgmdDAsIE5VTEwpOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwg
bl90aDsgaSsrKSB7CiAgICAgICAgICAgIGlmICgoZSA9IHB0aHJlYWRfY3JlYXRlICgmdGlkW2ld
LCBOVUxMLCBydW4sIE5VTEwpKSAhPSAwKSB7CiAgICAgICAgICAgICAgICBwcmludGYgKCJwdGhy
ZWFkX2NyZWF0ZSAlZDogJXNcbiIsIGksIHN0cmVycm9yKGUpKTsKICAgICAgICAgICAgICAgIHJl
dHVybiAoMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIGNvbGxlY3QKICAg
ICAgICBmb3IgKGludCBpID0gMDsgaSA8IG5fdG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L3Rv
dF93YWxsKTsKCiAgICAgICAgcmV0dXJuICgwKTsKfQo=
--00000000000029158f05bad8cbec--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAL98DL44SPbiT9EHuxrDSzttUyv0coj6nGNJ2VpYArsfujP_bg>