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 ECEE06EC5F; Wed, 21 Apr 2021 16:13:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org ECEE06EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619010782; bh=sLv8MnobF8HXhLjXE3pqFnQNM1LISxrlt0Z0svsRseI=; 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=oZ2DcK/ahGnooqHUEcz0MFGHjXWLJz2mLphzNUpKMZjb2L+uSyWnq3cxRsJ7z4BTB D+oE7bVqfvJkB0uCM8Ucg9xdeXbCszUjDWEAMdBnXK79pFv9sqXxrGhn5GMRVSeOOe 6IXcqSScwiVHcbqnYS6FxHzHUP4XjDHXIzD5VwNc= 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 47D116EC5F for ; Wed, 21 Apr 2021 16:12:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47D116EC5F Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lZCf4-0001O0-DV; Wed, 21 Apr 2021 16:12:58 +0300 To: Sergey Kaplun , Roman Khabibov Cc: tarantool-patches@dev.tarantool.org References: <20210311054949.91263-1-roman.habibov@tarantool.org> <20210314124220.GA16737@root> Message-ID: <092bc107-40cd-2c58-7a90-236663551249@tarantool.org> Date: Wed, 21 Apr 2021 16:12:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9DD7F0C977691F2B1F851B0272AA9F8A33FACE8A54B4B77F1182A05F538085040392BDEA32E33768BC04137F03836966806DE4DC083940BE90AD92223F5723450 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE721D130CF676D2164EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BC9F889FE9D346E88638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B231EA359EDFB6A2884C1AB696C897275E16A3AA18C56759C2D2E47CDBA5A96583C09775C1D3CA48CFCA5A41EBD8A3A0199FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3CA5A41EBD8A3A0199FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F616AD31D0D18CD5C35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A57FF8C2385827B29CC85995B6D187E87886CC98D9A6DCBC6DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349320586B19AD2C728C5F646A4183E3CCEDB67214FD5996F4184C7489BF5F0CDF4B3474C4C4D4823B1D7E09C32AA3244C28D3AA47D2B5574EE84D97FB4E10EBC5F2F5F14F68F1805BFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojd3ipC3Yuge2pHz1biCm5bg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822F3770EB9312FD58A9EFB0302CEEB79E6DD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] serializer: serialize recursive structures 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: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 21.04.2021 12:27, Sergey Kaplun via Tarantool-patches wrote: > Hi! > > Thanks for the fixes and the benchmarks! I propose an updated version of script and propose to add benchmark as a part of patch series. --[[ -- measure serialization time -- run: taskset -c 1 tarantool perf.lua ]] local clock = require('clock') local function elapsed(f, n)     local t0 = clock.monotonic()     for i = 1, n do         f()     end     local t1 = clock.monotonic()     return t1 - t0 end -- Get the mean of a table function calculate_mean(t)   local sum = 0   local count= 0   for k, v in pairs(t) do     if type(v) == 'number' then       sum = sum + v     end   end   return (sum/#t) end -- Get the median of a table. function calculate_median(t)   local temp = {}   -- deep copy table so that when we sort it, the original is unchanged   -- also weed out any non numbers   for k, v in pairs(t) do     if type(v) == 'number' then       table.insert(temp, v)     end   end   table.sort(temp)   -- If we have an even number of table elements or odd.   if math.fmod(#temp,2) == 0 then     -- return mean value of middle two elements     return (temp[#temp/2] + temp[(#temp/2)+1]) / 2   else     -- return middle element     return temp[math.ceil(#temp/2)]   end end -- Get the standard deviation of a table function calculate_stddev(t)   local vm   local sum = 0   local mean = calculate_mean(t)   for k, v in pairs(t) do     if type(v) == 'number' then       vm = v - mean       sum = sum + (vm * vm)     end   end   return math.sqrt(sum/(#t - 1)) end local function timeit(f, name)     print('======================================')     print(name)     print('======================================')     local res = {}     local iterations = 10     local elapsed_time = 0     local repetitions = 150000     for j = 1, iterations do         -- warming         for i = 1, 100 do f() end         -- measurement         elapsed_time = elapsed(f, repetitions)         table.insert(res, elapsed_time)         print(string.format("%-2d - %f sec / %d repetitions", j, elapsed_time, repetitions))     end     print(string.format("time mean   %f", calculate_mean(res)))     print(string.format("time median %f", calculate_median(res)))     print(string.format("time stddev %f", calculate_stddev(res))) end local t = {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} timeit(function()            local console = require('console')            console.set_default_output('yaml')            return console.eval(tostring(t))        end, 'serializer console yaml') timeit(function()            local console = require('console')            console.set_default_output('lua')            return console.eval(tostring(t))        end, 'serializer console lua') timeit(function()            local serializer = require('json')            serializer.cfg({encode_max_depth = 64})            return serializer.encode(t)        end, 'serializer json') timeit(function()            local serializer = require('yaml')            serializer.cfg({encode_max_depth = 64})            return serializer.encode(t)        end, 'serializer yaml') timeit(function()            local serializer = require('msgpack')            serializer.cfg({encode_max_depth = 64})            return serializer.encode(t)        end, 'serializer msgpack') timeit(function()            local serializer = require('msgpackffi')            return serializer.encode(t)        end, 'serializer msgpackffi')