Date: Mon, 30 Jan 2017 20:05:31 -0800 From: Conrad Meyer <cem@freebsd.org> To: freebsd-gecko@freebsd.org Subject: Excessive getpid() in Firefox Message-ID: <CAG6CVpX4Np_pv0vqaGfM6U6DTWty758kVNOvY9KkHChPKYKMZw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi, (I'm not subscribed to the list, so please CC me in replies.) Several people reported seeing excessive getpid(2) calls in Firefox (thousands per second). Mark Johnston did a quick dtrace profile, which pointed to libnss3.so`PK11_DigestFinal+0xf6. I dug a little in the NSS source code. While there is nothing too obvious in PK11_DigestFinal itself, I located a probable culprit: the fork detection logic in "softtokens." The codebase can detect forks using either pthread_atfork(3) or repeatedly checking getpid(2). Unfortunately, today it only uses the more efficient pthread_atfork(3) approach on glibc-based operating systems. The good news is that FreeBSD implements pthread_atfork(3), and (as suggested as required by a nearby code comment) deregisters callbacks located in dlclose(3)ed shared objects. So it should be possible to enable CHECK_FORK_PTHREAD for FreeBSD in NSS, eliminating one source of slowdown in NSS and Firefox. I've filed a Mozilla bug tracking this here: https://bugzilla.mozilla.org/show_bug.cgi?id=1335284 Note that I haven't actually tested Firefox with this change, so I wouldn't go ahead and commit anything just yet. Konstantin suggested I email this list in case there is some interest in testing / driving this change at Mozilla. Thanks, Conrad
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpX4Np_pv0vqaGfM6U6DTWty758kVNOvY9KkHChPKYKMZw>