Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tarantool tx thread event loop speed #123

Closed
filonenko-mikhail opened this issue Sep 24, 2020 · 2 comments · Fixed by #346
Closed

Tarantool tx thread event loop speed #123

filonenko-mikhail opened this issue Sep 24, 2020 · 2 comments · Fixed by #346
Labels
feature A new functionality

Comments

@filonenko-mikhail
Copy link
Contributor

Motivation

In case when there is some heavy fiber or fibers amount is big it's possible that fiber takes control too late.

For e.g. if fiber has some timeout logic, timeout can be triggered even if necessary data is arrived in buffer.

for e.g.

while clock.now() < deadline do
  local payload = sock.read(100, timeout=0.1)
end
-- payload is ignored
if clock.now() >= deadline then
  error
end

Propolsal

Measure tx thread event loop speed with special fiber

require('strict')
local log = require('log')
local clock = require('clock')
local fiber = require('fiber')
local metrics = require('metrics')

local timeout = 1

local tx_loop_delay_gauge = metrics.gauge('tnt_tx_loop_delay', 'Tarantool tx thread event loop delay')
if rawget(_G, '__metrics_tx_speed') == nil then
    _G.__metrics_tx_speed = fiber.new(function ()
            fiber.self():name("tx_speed")

            while true do
                local start = clock.monotonic64()
                fiber.sleep(tonumber(timeout))
                local diff = clock.monotonic64() - start
                local err = (tonumber(diff) - timeout*1e9)/1e9

                if err < 0 then
                    --log.info("Early wakeup %f", err)
                elseif err > 0 then
                    --log.info('Event loop slower by %f seconds', err)
                end
                tx_loop_delay_gauge:set(timeout + err)
            end
    end)
end
@vasiliy-t vasiliy-t added the feature A new functionality label Oct 20, 2020
@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

@github-actions
Copy link

github-actions bot commented Jun 8, 2021

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants