From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 120326EC5D; Mon, 5 Apr 2021 19:23:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 120326EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617639793; bh=1QmrEeRFAOEVOlsL+h0CxNjt0KBCx1cmCiTOJSQNfK8=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=H07jwaLIpFUaE8rpKtMS1cVZcthUZgJOhJq/KDlwlrxlzXrkfqZ1iA8l+hDd6Azzc sk8V5l60F0gxbGgZLcv8TOi5JmsSAk3ikdB34RF3Zqhmcx93udQlxE3/XZQHlSzIWe Oa5+PSMHzx060iFmJOeVfhIiMXsl8xzTjziePDvY= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.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 9D64E6EC5D for ; Mon, 5 Apr 2021 19:23:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9D64E6EC5D Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lTS0M-0001oo-AC; Mon, 05 Apr 2021 19:23:11 +0300 To: Serge Petrenko , alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <44f4b260e0ac435fe78282c1f6f4607159914935.1617375300.git.sergepetrenko@tarantool.org> <6216debc-5807-ede1-df21-823d60a1e70b@tarantool.org> Message-ID: <36dca5a2-9e18-e517-78d2-827b85cbc3e1@tarantool.org> Date: Mon, 5 Apr 2021 18:23:09 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <6216debc-5807-ede1-df21-823d60a1e70b@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E32947A0146560F8BA70927CAA5B950F38D9F182A05F5380850403AFC49CD809F277FDF4613E372126766B8526FB1DB88B630F06CF5DF5D411F55 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71107D7B19CDFFE90EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006373C710FAF3667BB888638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C16EE06F5A270FE6A10AF341F9C3DBA1380F17F6D88C11983A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE77E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E954A0C70C50C109CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7C13763150CD373CE731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A56E4C2F732AED09D46950CCE66DB6687C920EB1E1BF99DA87D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C6EC1BD9807109D23B4C6F51EA4BBC8E46C5EF09AA7B9613AA5FB9F288F18E78197994DB07EE50DC1D7E09C32AA3244C8DE222784E2E5973EBCD126935D044C895A9E0DC41E9A4CFFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojM00ve/f+0okogy5bMqMB9Q== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382277A3A2A0A8D0B628050C1B9E7A6F1E0F3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 4/4] feedback_daemon: generate report right before sending X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! The patch is mostly fine, but I don't see why would we need it, as well as why do we need to know when a first space is created. I don't argue, only making a note. Unless it would affect the perf or normal code base complexity anyhow. See 2 comments below. > diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua > index 0aab189b6..ca93b7574 100644 > --- a/src/box/lua/feedback_daemon.lua > +++ b/src/box/lua/feedback_daemon.lua > @@ -358,12 +363,26 @@ local function guard_loop(self) >      self.shutdown:put("stopped") >  end > > +local function save_event(self, event) > +    if type(event) ~= 'string' then > +        error("Usage: box.internal.feedback_daemon.save_event(string)") > +    end > +    local cnt = self.cached_events[event] or 0 1. cnt is unused. Did it pass luacheck? I suppose you wanted something like this: ==================== @@ -367,9 +367,9 @@ local function save_event(self, event) if type(event) ~= 'string' then error("Usage: box.internal.feedback_daemon.save_event(string)") end - local cnt = self.cached_events[event] or 0 - self.cached_events[event] = (self.cached_events[event] or 0) + 1 - if self.cached_events[event] == 1 then + local cnt = (self.cached_events[event] + 1) or 1 + self.cached_events[event] = cnt + if cnt == 1 then -- The first occurred event of this type triggers report dispatch -- immediately. self.send() ==================== > diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua > index 96503a50e..cf1b070af 100644 > --- a/src/box/lua/schema.lua > +++ b/src/box/lua/schema.lua > @@ -462,6 +462,10 @@ box.schema.space.create = function(name, options) >      }) >      _space:insert{id, uid, name, options.engine, options.field_count, >          space_options, format} > + > +    if internal.feedback_daemon ~= nil then > +        internal.feedback_daemon.save_event("create_space") 2. To make it less ugly you could save feedback_daemon into a local variable in this file, and access it as an upvalue in all the usages. Or wrap the entire 'save_event' thing here into a function which checks that the daemon is not nil, and then call its save_event function.