femalloc - cross-thread malloc based on dlmalloc ------------------------------------------------ femalloc is general-purpose malloc implementation focused on multi-threaded POSIX applications which allocate and free across different threads. It aims to be space and time-efficient while maintaining predictable behavior. The predictable cross-thread behavior is designed with users of Userspace-RCU [URCU] in mind. femalloc itself uses the Wait-Free Concurrent Queue (wfcqueue) distributed with URCU, but does not use RCU internally. wfcqueue allows femalloc to release memory back to the thread which originally made the allocation, not necessarily the thread which calls `free'. This makes femalloc suitable for existing users of URCU which free memory via `call_rcu' as well as any applications which share and communicate allocations across threads. femalloc is also great for single-threaded applications as there is minimal synchronization overhead. femalloc should also perform well with garbage collectors in multi-threaded applications, as garbage collectors in multi-threaded applications often ends up freeing memory in a different thread than the one which made the allocation. femalloc is based on the venerable dlmalloc 2.8.6 written by Doug Lea available at ftp://gee.cs.oswego.edu/pub/misc/malloc.c dlmalloc 2.8.x includes built-in arena support (aka "mspaces"), which made it easy for us build femalloc on top of it by adding wfcqueue support. [URCU] - http://urcu.so/ - Userspace Read-Copy-Update Weaknesses (things to fix) -------------------------- femalloc may be wasteful with ephemeral threads, using long-lived threads is recommended. We will fix this. Overheads for small allocations is large, we will fix this. We should avoid using too much space for for systems with overcommit disabled, will fix. We will support applications which spawn many more threads than CPUs, as we realize it is often easier to spawn extra threads to deal with APIs which lack non-blocking/asynchronous support. There are no supported runtime/environment tuning options, yet. Fragmentation behavior is not well-tested for some allocation patterns; probably needs fixing as the related ptmalloc2 (from glibc) behaves horribly sometimes. Memory is not released back to the OS automatically, only via calls to `malloc_trim'. Note: releasing memory back to the OS only to re-acquire it again is expensive. Linux 2.6-and later only for now, FreeBSD support coming. Platforms --------- femalloc is tuned with 2010s-era x86-64 systems running a modern Linux kernel in mind. We will support FreeBSD and other *BSDs as we find time and interest. Non-Free platforms are not supported, especially those which make overriding the system malloc implementation difficult. Install ------- We require a version of URCU with wfcqueue support. The latest version is recommended. See the `INSTALL' document distributed with femalloc or http://femalloc.80x24.org/INSTALL for more info. Source code ----------- Our source code is available via git and our mailing list-oriented development model follows that of git (and the Linux kernel) itself. git clone git://80x24.org/femalloc Mailing list ------------ All communication regarding femalloc is welcome to all via plain-text email to: mm@80x24.org No subscription is required to post, so reply-to-all. Do not send HTML email, it will be flagged as spam. It is recommended to use "git format-patch" and "git send-email" for formatting and sending patches. Use "git request-pull" to format pull request emails. Optional subscription is available by sending a message to: mm+subscribe@80x24.org List archives: http://80x24.org/mm/ You may also clone the archives via ssoma (some sort of mail archiver): LISTNAME=mm # or any name of your choosing ssoma add $LISTNAME git://80x24.org/mm/ $DESTINATION ssoma sync $LISTNAME See the ssoma README for more details: http://ssoma.public-inbox.org/README Homepage -------- This README is our homepage: http://femalloc.80x24.org/README We have better things to do than worry about the next browser bug because HTML/CSS/JS/fonts/images/video are all too complicated. Legal ----- Copyright (C) 2014, all contributors, see git://80x24.org/femalloc License: LGPLv2.1 or later femalloc is based on a public domain (explained at [CC0]) version of malloc/free/realloc written by Doug Lea (dlmalloc 2.8.6) The original version of dlmalloc is available at ftp://gee.cs.oswego.edu/pub/misc/ femalloc chooses the LGPL in order to use static inline functions exported by the Userspace RCU library . Non-concurrency-related improvements are encouraged to be placed in the public domain [CC0] so they may be used in future versions of dlmalloc by Doug Lea. [CC0] - http://creativecommons.org/publicdomain/zero/1.0/ Etymology --------- fe = fool's errand. That is what working on memory management feels like :P On a good day, one may think of it as a "fast+efficient malloc" :)