Bug #1532

jemalloc doesn't work on DragonFly

Added by hasso almost 5 years ago. Updated about 3 years ago.

Status:NewStart date:
Priority:LowDue date:
Assignee:sjg% Done:

0%

Category:-
Target version:-

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

History

#1 Updated by sjg over 4 years ago

grab

#2 Updated by alexh about 3 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(&mutex->lock);
./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

#3 Updated by vsrinivas about 3 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.

#4 Updated by vsrinivas about 3 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?

Also available in: Atom PDF