[packages/mimalloc] new

atler atler at pld-linux.org
Wed Dec 15 21:32:52 CET 2021


commit d65d30807324759c1fa2c9929c2d90824bb27335
Author: Jan Palus <atler at pld-linux.org>
Date:   Wed Dec 15 21:32:28 2021 +0100

    new

 mimalloc-build_type.patch |  12 +++++
 mimalloc.spec             | 115 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+)
---
diff --git a/mimalloc.spec b/mimalloc.spec
new file mode 100644
index 0000000..6bebae3
--- /dev/null
+++ b/mimalloc.spec
@@ -0,0 +1,115 @@
+Summary:	Compact general purpose allocator with excellent performance
+Name:		mimalloc
+Version:	1.7.3
+Release:	1
+License:	MIT
+Group:		Development/Libraries
+Source0:	https://github.com/microsoft/mimalloc/archive/v%{version}/%{name}-%{version}.tar.gz
+# Source0-md5:	2f1719aab9912c597c05ac04f02945e0
+Patch0:		%{name}-build_type.patch
+URL:		https://github.com/microsoft/mimalloc
+BuildRequires:	cmake >= 3.0
+BuildRequires:	rpmbuild(macros) >= 1.605
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+mimalloc (pronounced "me-malloc") is a general purpose allocator with
+excellent performance characteristics. Initially developed by Daan
+Leijen for the run-time systems of the Koka and Lean languages.
+Notable aspects of the design include:
+
+- small and consistent: the library is about 8k LOC using simple and
+  consistent data structures. This makes it very suitable to integrate
+  and adapt in other projects. For runtime systems it provides hooks for
+  a monotonic heartbeat and deferred freeing (for bounded worst-case
+  times with reference counting).
+- free list sharding: instead of one big free list (per size class) we
+  have many smaller lists per "mimalloc page" which reduces
+  fragmentation and increases locality -- things that are allocated
+  close in time get allocated close in memory. (A mimalloc page contains
+  blocks of one size class and is usually 64KiB on a 64-bit system).
+- free list multi-sharding: the big idea! Not only do we shard the
+  free list per mimalloc page, but for each page we have multiple free
+  lists. In particular, there is one list for thread-local free
+  operations, and another one for concurrent free operations. Free-ing
+  from another thread can now be a single CAS without needing
+  sophisticated coordination between threads. Since there will be
+  thousands of separate free lists, contention is naturally distributed
+  over the heap, and the chance of contending on a single location will
+  be low -- this is quite similar to randomized algorithms like skip
+  lists where adding a random oracle removes the need for a more complex
+  algorithm.
+- eager page reset: when a "page" becomes empty (with increased chance
+  due to free list sharding) the memory is marked to the OS as unused
+  ("reset" or "purged") reducing (real) memory pressure and
+  fragmentation, especially in long running programs.
+- secure: mimalloc can be built in secure mode, adding guard pages,
+  randomized allocation, encrypted free lists, etc. to protect against
+  various heap vulnerabilities. The performance penalty is usually
+  around 10% on average over our benchmarks.
+- first-class heaps: efficiently create and use multiple heaps to
+  allocate across different regions. A heap can be destroyed at once
+  instead of deallocating each object separately.
+- bounded: it does not suffer from blowup, has bounded worst-case
+  allocation times (wcat), bounded space overhead (~0.2% meta-data, with
+  at most 12.5% waste in allocation sizes), and has no internal points
+  of contention using only atomic operations.
+- fast: In our benchmarks, mimalloc outperforms other leading
+  allocators (jemalloc, tcmalloc, Hoard, etc), and often uses less
+  memory. A nice property is that it does consistently well over a wide
+  range of benchmarks. There is also good huge OS page support for
+  larger server programs.
+
+%package devel
+Summary:	Header files for the mimalloc library
+Group:		Development/Libraries
+Requires:	%{name} = %{version}-%{release}
+
+%description devel
+Header files for mimalloc library.
+
+%package static
+Summary:	Static mimalloc library
+Group:		Development/Libraries
+Requires:	%{name}-devel = %{version}-%{release}
+
+%description static
+Static mimalloc library.
+
+%prep
+%setup -q
+%patch0 -p1
+
+%build
+%cmake -B build \
+	-DMI_INSTALL_TOPLEVEL:BOOL=ON
+
+%{__make} -C build
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} -C build install \
+	DESTDIR=$RPM_BUILD_ROOT
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post	-p /sbin/ldconfig
+%postun	-p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libmimalloc.so.1.7
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libmimalloc.so
+%{_includedir}/mimalloc.h
+%{_includedir}/mimalloc-new-delete.h
+%{_includedir}/mimalloc-override.h
+%{_libdir}/cmake/mimalloc
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libmimalloc.a
diff --git a/mimalloc-build_type.patch b/mimalloc-build_type.patch
new file mode 100644
index 0000000..d918354
--- /dev/null
+++ b/mimalloc-build_type.patch
@@ -0,0 +1,12 @@
+--- mimalloc-1.7.3/CMakeLists.txt.orig	2021-11-15 01:47:50.000000000 +0100
++++ mimalloc-1.7.3/CMakeLists.txt	2021-12-15 20:11:18.521257503 +0100
+@@ -247,9 +247,6 @@
+ endif()
+ 
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LC)
+-if(NOT(CMAKE_BUILD_TYPE_LC MATCHES "^(release|relwithdebinfo|minsizerel|none)$"))
+-  set(mi_basename "${mi_basename}-${CMAKE_BUILD_TYPE_LC}") #append build type (e.g. -debug) if not a release version
+-endif()
+ if(MI_BUILD_SHARED)
+   list(APPEND mi_build_targets "shared")
+ endif()
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mimalloc.git/commitdiff/d65d30807324759c1fa2c9929c2d90824bb27335



More information about the pld-cvs-commit mailing list