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 706687030D; Wed, 24 Feb 2021 13:35:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 706687030D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614162952; bh=pwkUPLbGzvDye6z4PNtxitjhyAhjsF2twO0mPkNcLmk=; 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=pTuynreopKCM4Dwnp02axTaNr+2rYpmR1XcDBl71haD15naeWE3I8yQOGLj8FtaIy 0hfuM5HWXo4hLibOZCHzr0JHcGY7nBhzoPp4/6f9v3jGq8eDqt98kvHLGGgVGGr0uZ 5Zc8lHWs1TaEHcfWBgpHbrHMTeX+qcPr8IpHPM5Y= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (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 4E2FC7030D for ; Wed, 24 Feb 2021 13:35:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4E2FC7030D Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1lErWI-0004X5-FA; Wed, 24 Feb 2021 13:35:51 +0300 To: Cyrill Gorcunov Cc: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org References: <20210212112541.27561-1-sergepetrenko@tarantool.org> <57b04874-1bb7-3d62-856d-b60df700514a@tarantool.org> <774363df-6be5-a7b4-ea7f-d72903f3c409@tarantool.org> Message-ID: Date: Wed, 24 Feb 2021 13:35:49 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; 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: ru X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD975C3EC174F566922928A658C60196E87DF7449A63D990329182A05F5380850401A901FB569F536031C242E40094B7010E945FB8618079D5961261D68F60FCDC7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71107D7B19CDFFE90EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374B2D40F594293EAD8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC37516A8786216141C2B72DFCD243F9D27E0B828548C6E156389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C04CF195F1528592878941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6197FFA0EFC27E0ACA471835C12D1D977C4224003CC836476EC64975D915A344093EC92FD9297F6718AA50765F7900637ED7DFAFE1016008EA7F4EDE966BC389F395957E7521B51C24C7702A67D5C33162DBA43225CD8A89FCBE33A7817EDC1EF6D8C47C27EEC5E9FB5C8C57E37DE458B4C7702A67D5C3316FA3894348FB808DB48C21F01D89DB561574AF45C6390F7469DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20BDD0D5C1FF1EAB3C3D91BBB18BA60722F X-C1DE0DAB: 0D63561A33F958A572206FD5109D9B32E9DE35C87AF127FD84B5E49BC1647C7DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7557E988E9157162368E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343C45ADCD169245FAE3B5138270F77837E516D3496E8F6D6B1FD835BF2FD20199E07D0A580E3A11F31D7E09C32AA3244C28D8C713FB60F9F9745F91CB7FCDB57EA90944CA99CF22E3FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyK6JYJ15DtLToAO56m0yxA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A44676723475C2EB9C7F75BCB22C88EDF74B6CD6F75EA07660E8424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] relay: yield explicitly every N sent rows 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 24.02.2021 13:15, Cyrill Gorcunov пишет: > On Wed, Feb 24, 2021 at 12:48:07PM +0300, Serge Petrenko wrote: > ... >>>>> 1. But it is not a size of anything, right? Maybe make it >>>>> int64_t then? >>>> uint64_t, probably? >>> Nope, int64_t. It is supposed to be 'faster'. Because it does >>> not have defined overflow rules, and therefore the hardware does >>> not need to handle it. >>> >>> But honestly, I didn't measure. For me it is more cargo cult. I >>> just use signed integers where I can assuming that the hardware >>> really may omit an instruction or so. >>> >>> Up to you. >> Long story short, I'd like to leave it as is. Besides, we have an unsigned >> type (size_t) in local recovery. >> >> Ok, now I see what you meant. >> I never thought of this, and brief googling showed no signs of a speedup >> with signed arithmetic vs unsigned. >> >> Actually, the standard says signed overflow is an undefined behaviour while >> an unsigned overflow should result in a wrap (modulo 2^64 in our case). >> >> Do you think this wrap may be costly on some architecture? > Addition on hardware level _always_ setup OF/CF flags so in this term it > doesn't matter which to use int64 or uint64 (iow hw treats addition as > signed integers all the time and it is up you how you gonna use this > flags in later code). > > What is more interesting is that older compilers (at least gcc) generate > more efficient code for *signed* integers, ie int64_t. I've been pretty > surprised when discovered this. I dont get you a reference because I > don't remember the exact versions though. In summary: rule of thumb > is to use signed integers if you really need some addition in a cycle. > For more rare access unsigned is more that enough and latest gcc already > can handle it the same way as signed numbers. Thanks for your answer! What do you propose? Should I hange it to int64_t then? -- Serge Petrenko