datastruct/existence: link the uperf tests against jemalloc, not tcmalloc

The two *_uperf targets link -ltcmalloc unconditionally.  On a box that does not
have gperftools installed, that link fails, and since existence_3hash_uperf is
the third of the ten programs in PROGS, make stops there: two of the ten get
built.  A hardcoded -l on an optional dependency turns one missing package into
a directory that does not build.

The allocator itself is not optional, and the NOTE above these rules has said so
since 2015.  Both tests allocate and free an existence group, along with the keys
and elements it commits, on every rotation on every updater thread, so glibc
malloc's arena contention limits them well before the technique under test does.
On a two-socket 96-core (384-hardware-thread) AMD EPYC 9654, at the default
parameters, ns/rotation as the median of five two-second runs:

	updaters               1      8     32     96    192
	3hash, glibc        1804   2541   3822   7504  20019
	3hash, jemalloc     1387   2211   2563   3635   5498
	                   1.30x  1.15x  1.49x  2.06x  3.64x

	3skiplist, glibc    3547  13868  28616  39992  68691
	3skiplist, jemalloc 3389  13205  27178  35237  52335
	                   1.05x  1.05x  1.05x  1.13x  1.31x

So use pkg-config to find jemalloc and link against it when it is installed, fall
back to glibc malloc when it is not -- with a note at build time, because the
numbers above are what that fallback costs -- and let MALLOC override either
choice, including back to tcmalloc for anyone who has it:

	make MALLOC=-ltcmalloc
	make MALLOC=		# glibc malloc

This subsumes the NOTE's -I/-L/--rpath recipe for a jemalloc installed under a
home directory, so the NOTE is rewritten to describe what the rules now do.

Linking jemalloc also defines USE_JEMALLOC, under which both tests set
percpu_arena:percpu through jemalloc's application-defined malloc_conf symbol, so
that linking is all it takes.  That is the closest analogue of the per-CPU caches
tcmalloc was providing here, which keeps the default build close to what these
tests used to measure.  It is not where the speedup comes from, and I would
rather say so than imply otherwise: the updaters are pinned by run_on(), so
jemalloc's default thread-bound arenas are already CPU-stable, and percpu_arena
measures as a wash against them across the sweep above (0.98x-1.07x, no trend),
at identical peak RSS.  It is what one wants if the pinning ever goes away, and
MALLOC_CONF in the environment still overrides it, so
MALLOC_CONF=percpu_arena:disabled measures exactly that.

The other eight programs in this directory are unchanged.  They are correctness
tests rather than update-rate benchmarks, and keep the system allocator.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
3 files changed