valkey/deps/jemalloc
Oran Agra d4e7ffb38c
Improve active defrag in jemalloc 5.2 (#9778)
Background:
Following the upgrade to jemalloc 5.2, there was a test that used to be flaky and
started failing consistently (on 32bit), so we disabled it ​(see #9645).

This is a test that i introduced in #7289 when i attempted to solve a rare stagnation
problem, and it later turned out i failed to solve it, ans what's more i added a test that
caused it to be not so rare, and as i mentioned, now in jemalloc 5.2 it became consistent on 32bit.

Stagnation can happen when all the slabs of the bin are equally utilized, so the decision
to move an allocation from a relatively empty slab to a relatively full one, will never
happen, and in that test all the slabs are at 50% utilization, so the defragger could just
keep scanning the keyspace and not move anything.

What this PR changes:
* First, finally in jemalloc 5.2 we have the count of non-full slabs, so when we compare
  the utilization of the current slab, we can compare it to the average utilization of the non-full
  slabs in our bin, instead of the total average of our bin. this takes the full slabs out of the game,
  since they're not candidates for migration (neither source nor target).
* Secondly, We add some 12% (100/8) to the decision to defrag an allocation, this is the part
  that aims to avoid stagnation, and it's especially important since the above mentioned change
  can get us closer to stagnation.
* Thirdly, since jemalloc 5.2 adds sharded bins, we take into account all shards (something
  that's missing from the original PR that merged it), this isn't expected to make any difference
  since anyway there should be just one shard.

How this was benchmarked.
What i did was run the memefficiency test unit with `--verbose` and compare the defragger hits
and misses the tests reported.
At first, when i took into consideration only the non-full slabs, it got a lot worse (i got into
stagnation, or just got a lot of misses and a lot of hits), but when i added the 10% i got back
to results that were slightly better than the ones of the jemalloc 5.1 branch. i.e. full defragmentation
was achieved with fewer hits (relocations), and fewer misses (keyspace scans).
2021-11-21 13:35:39 +02:00
..
bin Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
build-aux Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
doc Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
include Improve active defrag in jemalloc 5.2 (#9778) 2021-11-21 13:35:39 +02:00
m4 Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
msvc Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
scripts Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
src fix a rare active defrag edge case bug leading to stagnation 2021-10-12 12:55:35 +03:00
test Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.appveyor.yml Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.autom4te.cfg Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.cirrus.yml Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.gitattributes Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.gitignore Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
.travis.yml Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
autogen.sh Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
ChangeLog Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
config.stamp.in Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
configure Generate configure for Jemalloc 5.2.1. 2021-10-10 18:29:13 +03:00
configure.ac Fix compilation warnings in Lua and jemalloc dependencies (#7785) 2021-10-12 12:55:35 +03:00
COPYING Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
INSTALL.md Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
jemalloc.pc.in Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
Makefile.in Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
README Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
run_tests.sh Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
TUNING.md Merge commit '220a0f0880419450c9409202aac1fab4b8be0719' as 'deps/jemalloc' 2021-10-10 18:26:48 +03:00
VERSION Generate configure for Jemalloc 5.2.1. 2021-10-10 18:29:13 +03:00

jemalloc is a general purpose malloc(3) implementation that emphasizes
fragmentation avoidance and scalable concurrency support.  jemalloc first came
into use as the FreeBSD libc allocator in 2005, and since then it has found its
way into numerous applications that rely on its predictable behavior.  In 2010
jemalloc development efforts broadened to include developer support features
such as heap profiling and extensive monitoring/tuning hooks.  Modern jemalloc
releases continue to be integrated back into FreeBSD, and therefore versatility
remains critical.  Ongoing development efforts trend toward making jemalloc
among the best allocators for a broad range of demanding applications, and
eliminating/mitigating weaknesses that have practical repercussions for real
world applications.

The COPYING file contains copyright and licensing information.

The INSTALL file contains information on how to configure, build, and install
jemalloc.

The ChangeLog file contains a brief summary of changes for each release.

URL: http://jemalloc.net/