Project

General

Profile

Actions

Bug #1532

open

jemalloc doesn't work on DragonFly

Added by hasso about 15 years ago. Updated over 13 years ago.

Status:
New
Priority:
Low
Assignee:
Category:
-
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

jemalloc is a malloc(3) implementation from FreeBSD and for some reason
increasingly popular in various software pieces dealing ECMAscript and related
stuff. This means browsers (Firefox, Chrome), but also Gnash for example.
Unfortunately jemalloc doesn't work with DragonFly. Matt explained why some
time ago:

http://leaf.dragonflybsd.org/mailarchive/users/2009-04/msg00162.html

Actions #1

Updated by sjg over 14 years ago

grab

Actions #2

Updated by alexh over 13 years ago

Sam, have you looked into this? jemalloc seems to use _SPINLOCK in some cases,
depending on how the defines are set up, short grep:

./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#else
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c:static
malloc_mutex_t init_lock = {_SPINLOCK_INITIALIZER};
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#endif
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
return (true);
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#elif
defined(MOZ_MEMORY_DARWIN)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c: mutex->lock =
OS_SPINLOCK_INIT;
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#elif
defined(MOZ_MEMORY_LINUX) && !defined(MOZ_MEMORY_ANDROID)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
pthread_mutexattr_t attr;
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- return
(true);
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#else
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c: static const
spinlock_t lock = SPINLOCK_INITIALIZER;
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- mutex->lock = lock;
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#else
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- if (
_isthreaded)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c:
SPINLOCK;
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#endif
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-}
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
return (true);
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#elif
defined(MOZ_MEMORY_DARWIN)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c: lock->lock =
OS_SPINLOCK_INIT;
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#elif
defined(MOZ_MEMORY_LINUX) && !defined(MOZ_MEMORY_ANDROID)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-
pthread_mutexattr_t attr;
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- return
(true);
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#else
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c: lock->lock =
_SPINLOCK_INITIALIZER;
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#endif
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- return (false);
--
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#else
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c- if (
_isthreaded)
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c:
_SPINLOCK(&lock->lock);
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-#endif
./www/firefox/work/mozilla-release/memory/jemalloc/jemalloc.c-}

So in principle it shouldn't be too hard to get it to work. I'll have a look
myself tonight and see what can be done, but maybe you've already made some
progress on this?

Cheers,
Alex

Actions #3

Updated by vsrinivas over 13 years ago

In my homedirectory on leaf, there is a jemalloc subdir; that is a version
ported to run on DragonFly. Diff against the version in FreeBSD 8 for exactly
what is changed.

Actions #4

Updated by vsrinivas over 13 years ago

Looking into it, my port just uses _SPINLOCK for malloc_mutexes; to be able to
do so, we'd need to include /usr/src/lib/libc/include/libc_private.h ; it'd be a
bit of a shame if Firefox's code had to do the same.

Under what conditions are _SPINLOCKs used?

Actions

Also available in: Atom PDF