Skip to content

Commit

Permalink
core.app: set timeline log level at the very end of breathe loop
Browse files Browse the repository at this point in the history
This fixes a bug where timeline log level was rerolled between end of breaths
but before before post-breath events, causing sampling to affect the event lag
of the polled_timers event.
  • Loading branch information
eugeneia committed Nov 8, 2018
1 parent debd26c commit edaad6c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ function main (options)
breathe()
if not no_timers then timer.run() events.polled_timers() end
if not busywait then pace_breathing() end
set_log_level() -- roll random log level
until done and done()
counter.commit()
if not options.no_report then report(options.report) end
Expand All @@ -562,6 +563,19 @@ function main (options)
setvmprofile("program")
end

function set_log_level (level)
if not level then
-- Randomize the log level. Enable each level in 5x more breaths
-- than the level below by randomly picking from log5() distribution.
-- Goal is ballpark 1000 messages per second (~15min for 1M entries.)
--
-- Could be better to reduce the log level over time to "stretch"
-- logs for long running processes? Improvements possible :-).
level = math.max(1, math.ceil(math.log(math.random(5^9))/math.log(5)))
end
timeline_mod.level(timeline_log, level)
end

local nextbreath
local lastfrees = 0
local lastfreebits = 0
Expand Down Expand Up @@ -643,14 +657,6 @@ function breathe ()
events.commited_counters()
packet.rebalance_freelists()
end
-- Randomize the log level. Enable each level in 5x more breaths
-- than the level below by randomly picking from log5() distribution.
-- Goal is ballpark 1000 messages per second (~15min for 1M entries.)
--
-- Could be better to reduce the log level over time to "stretch"
-- logs for long running processes? Improvements possible :-).
local level = math.max(1, math.ceil(math.log(math.random(5^9))/math.log(5)))
timeline_mod.level(timeline_log, level)
running = false
end

Expand Down

0 comments on commit edaad6c

Please sign in to comment.