Add "thread.idle" mallctl.

This can encapsulate various internal cleaning logic, and can be used to free up
resources before a long sleep.
This commit is contained in:
David Goldblatt
2020-01-22 11:13:26 -08:00
committed by David Goldblatt
parent f81341a48b
commit 6a622867ca
3 changed files with 137 additions and 2 deletions

View File

@@ -1654,6 +1654,28 @@ malloc_conf = "xmalloc:true";]]></programlisting>
default.</para></listitem>
</varlistentry>
<varlistentry id="thread.idle">
<term>
<mallctl>thread.idle</mallctl>
(<type>void</type>)
<literal>--</literal>
</term>
<listitem><para>Hints to jemalloc that the calling thread will be idle
for some nontrivial period of time (say, on the order of seconds), and
that doing some cleanup operations may be beneficial. There are no
guarantees as to what specific operations will be performed; currently
this flushes the caller's tcache and may (according to some heuristic)
purge its associated arena.</para>
<para>This is not intended to be a general-purpose background activity
mechanism, and threads should not wake up multiple times solely to call
it. Rather, a thread waiting for a task should do a timed wait first,
call <link linkend="thread.idle"><mallctl>thread.idle</mallctl><link> if
no task appears in the timeout interval, and then do an untimed wait.
For such a background activity mechanism, see
<link linked="background_thread"><mallctl>background_thread</mallctl></link>.
</para></listitem>
</varlistentry>
<varlistentry id="tcache.create">
<term>
<mallctl>tcache.create</mallctl>