Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lua: add fiber.top() listing fiber cpu consumption
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() --- - 1: cpu average (%): 10.779696493982 cpu instant (%): 10.435256168573 115: cpu average (%): 5.4571279061075 cpu instant (%): 5.9653973440576 120: cpu average (%): 21.944382148464 cpu instant (%): 23.849021825646 116: cpu average (%): 8.6603872318158 cpu instant (%): 9.6812031335093 119: cpu average (%): 21.933168871944 cpu instant (%): 20.007540530351 cpu misses: 0 118: cpu average (%): 19.342901995963 cpu instant (%): 16.932679820703 117: cpu average (%): 11.549674814981 cpu instant (%): 13.128901177161 ... ``` In the table above keys are fiber id's (and a single 'cpu misses' key which indicates the amount of times tx thread was rescheduled on a different cpu core. More on that later). The two metrics available for each fiber are: 1) cpu instant (per cent), which indicates the share of time fiber was executing during the previous event loop iteration 2) cpu average (per cent), which is calculated as an exponential moving average of `cpu instant` values over all previous event loop iterations. 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 lust measurement. This loweres precision of our computations, so the bigger `cpu misses` value the lower the precision of fiber.top() results.
- Loading branch information
1 parent
52e7822
commit eb924da
Showing
5 changed files
with
333 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.