summaryrefslogtreecommitdiffstats
path: root/daemon/bindings/worker.rst
blob: 9dfcbe83a9b83a34a8c05a02a795fca3f702f046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.. SPDX-License-Identifier: GPL-3.0-or-later

Scripting worker
^^^^^^^^^^^^^^^^

Worker is a service over event loop that tracks and schedules outstanding queries,
you can see the statistics or schedule new queries. It also contains information about
specified worker count and process rank.

.. envvar:: worker.id

   Value from environment variable ``SYSTEMD_INSTANCE``,
   or if it is not set, :envvar:`PID <worker.pid>` (string).

.. envvar:: worker.pid

   Current worker process PID (number).

.. function:: worker.stats()

   Return table of statistics.  See member descriptions in :c:type:`worker_stats`.
   A few fields are added, mainly from POSIX ``getrusage()``:

   * ``usertime`` and ``systime`` -- CPU time used, in seconds
   * ``pagefaults`` -- the number of hard page faults, i.e. those that required I/O activity
   * ``swaps`` -- the number of times the process was “swapped” out of main memory; unused on Linux
   * ``csw`` -- the number of context switches, both voluntary and involuntary
   * ``rss`` -- current memory usage in bytes, including whole cache (resident set size)

   Example:

   .. code-block:: lua

	print(worker.stats().concurrent)