Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Yukhin <kyukhin@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [tarantool-patches] [PATCH v3] lua: add fiber.top() listing fiber cpu consumption
Date: Sat, 9 Nov 2019 09:53:40 +0300	[thread overview]
Message-ID: <20191109065340.nghum2z473s62qbc@tarantool.org> (raw)
In-Reply-To: <20191101140523.14580-1-sergepetrenko@tarantool.org>

Hello,

On 01 ноя 17:05, Serge Petrenko wrote:
> Implement a new function in Lua fiber library: top(). It returns a table
> of alive fibers (including the scheduler). Each table entry has two
> fields: average cpu consumption, which is calculated with exponential
> moving average over event loop iterations, and current cpu consumption,
> which shows fiber's cpu usage over the last event loop iteration.
> The patch relies on CPU timestamp counter to measure each fiber's time
> share.
> 
> Closes #2694
> 
> @TarantoolBot document
> Title: fiber: new function `fiber.top()`
> 
> `fiber.top()` returns a table of all alive fibers and lists their cpu
> consumption. Let's take a look at the example:
> ```
> tarantool> fiber.top()
> ---
> - 104/lua:
>     instant: 18.433514726042
>     time: 0.677505865
>     average: 21.98826143184
>   103/lua:
>     instant: 19.131392015951
>     time: 0.689521917
>     average: 20.807772656431
>   107/lua:
>     instant: 18.624600174469
>     time: 0.681585168
>     average: 17.78194117452
>   101/on_shutdown:
>     instant: 0
>     time: 0
>     average: 0
>   105/lua:
>     instant: 18.562289702156
>     time: 0.682085309
>     average: 15.513811055476
>   106/lua:
>     instant: 18.441822789017
>     time: 0.677320271
>     average: 15.427595583115
>   102/interactive:
>     instant: 0
>     time: 0.000367182
>     average: 0
>   cpu misses: 0
>   1/sched:
>     instant: 6.8063805923649
>     time: 0.253035056
>     average: 8.3479789103691
> ...
> 
> ```
> In the table above keys are strings containing fiber ids and names
> (the only exception is a single 'cpu misses' key which indicates the
> number of times tx thread was rescheduled on a different cpu core.
> More on that later).
> The three metrics available for each fiber are:
> 1) instant (per cent),
> which indicates the share of time fiber was executing during the
> previous event loop iteration
> 2) average (per cent), which is calculated as an exponential moving
> average of `instant` values over all previous event loop iterations.
> 3) time (seconds), which estimates how much cpu time each fiber spent
> processing during its lifetime.
> 
> More info on `cpu misses` field returned by `fiber.top()`:
> `cpu misses` indicates the amount of times tx thread detected it was
> rescheduled on a different cpu core during the last event loop
> iteration.
> fiber.top() uses cpu timestamp counter to measure each fiber's execution
> time. However, each cpu core may have its own counter value (you can
> only rely on counter deltas if both measurements were taken on the same
> core, otherwise the delta may even get negative).
> When tx thread is rescheduled to a different cpu core, tarantool just
> assumes cpu delta was zero for the latest measurement. This loweres
> precision of our computations, so the bigger `cpu misses` value the
> lower the precision of fiber.top() results.
> 
> Fiber.top() doesn't work on arm architecture at the moment.
> 
> Please note, that enabling fiber.top() slows down fiber switching by
> about 15 per cent, so it is disabled by default.
> To enable it you need to issue `fiber.top_enable()`.
> You can disable it back after you finished debugging  using
> `fiber.top_disable()`.
> "Time" entry is also added to each fibers output in fiber.info()
> (it duplicates "time" entry from fiber.top()).
> Note, that "time" is only counted while fiber.top is enabled.
> ---
> https://github.com/tarantool/tarantool/issues/2694
> https://github.com/tarantool/tarantool/tree/sp/gh-2694-fiber-top

I've checked your patch into master.

--
Regards, Kirill Yukhin

      parent reply	other threads:[~2019-11-09  6:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 14:05 [Tarantool-patches] " Serge Petrenko
2019-11-02 17:12 ` Vladislav Shpilevoy
2019-11-05 14:42   ` [Tarantool-patches] [tarantool-patches] " Serge Petrenko
2019-11-06 14:02     ` Vladislav Shpilevoy
2019-11-09  6:53 ` Kirill Yukhin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191109065340.nghum2z473s62qbc@tarantool.org \
    --to=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] [PATCH v3] lua: add fiber.top() listing fiber cpu consumption' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox