From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp20.mail.ru (smtp20.mail.ru [94.100.179.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A96C4440F3C for ; Thu, 14 Nov 2019 01:45:49 +0300 (MSK) References: From: Vladislav Shpilevoy Message-ID: <649a8cbc-6861-1a9f-7463-457c043a6484@tarantool.org> Date: Wed, 13 Nov 2019 23:52:01 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 2/2] app/fiber: wait till a full event loop iteration ends. List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the path! We don't use dots in commit title. I guess this is a typo. On 13/11/2019 19:04, Serge Petrenko wrote: > fiber.top() fills in statistics every event loop iteration, > so if it was just enabled, fiber.top() may contain 'inf's and > 'nan's in fiber cpu usage averages because total time consumed by > the main thread was not yet accounted for. > Same stands for viewing top() results for a freshly created fiber: > its metrics will be zero since it hasn't lived a full ev loop iteration > yet. > Fix this by delaying the test till top() results are meaningful and add > minor refactoring. > > Follow-up #2694 > --- > test/app/fiber.result | 35 ++++++++++++++++++++++++++--------- > test/app/fiber.test.lua | 31 +++++++++++++++++++++++-------- > 2 files changed, 49 insertions(+), 17 deletions(-) > > diff --git a/test/app/fiber.result b/test/app/fiber.result > index 4a094939f..d447a36fc 100644 > --- a/test/app/fiber.result > +++ b/test/app/fiber.result > @@ -1469,6 +1469,19 @@ sum = 0 > fiber.top_enable() > --- > ... > +-- Check that a number is finite. > +-- Lua doesn't have this, sorry. > +function finite(num)\ > + return type(num) == 'number' and num < math.huge and\ > + num > -math.huge and tostring(num) ~= 'nan'\ 1. A canonical way to check for NaN is compare a value with itself. If they are not equal, then it is NaN. But more important questions are: - How can a number from top() have a not 'number' type? - How can top() contain a NaN, and an infinite value? > +end > +--- > +... > +-- Wait till a full event loop iteration passes, so that > +-- top() contains meaningful results. > +while not finite(fiber.top().cpu["1/sched"].instant) do fiber.yield() end 2. Double whitespace after 'do'.