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 DB6EC6EC56; Tue, 16 Mar 2021 02:42:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DB6EC6EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615851744; bh=9k1iYo9PAKVyDvaEPs/RC0e1ZHt5YJI/kFqXSmWPH4c=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=C5jHrHAjU9E2ec+VTAp0TwRzPpTuDiEvynjrluOSwUjUA9NdKjunwquLrQ2Dpb9gs g1NpuUb3g6S+c9jQv2hJ6r4EW7lFwhZ/Y4Y1cIHA+S01+btZs5yEXz4vQWYRplHRCX yzy6gzdcqo57y9ZB0TDyibV0ixTNiojudtCX/cmM= 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 EB7716EC56 for ; Tue, 16 Mar 2021 02:42:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EB7716EC56 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lLwqt-0005um-9t; Tue, 16 Mar 2021 02:42:23 +0300 To: Serge Petrenko , Konstantin Osipov , gorcunov@gmail.com, tarantool-patches@dev.tarantool.org References: <20210224193549.70017-1-sergepetrenko@tarantool.org> <26fde1bf-a972-fe03-fffe-818839718394@tarantool.org> <20210310081804.GA87351@starling> Message-ID: <54666e16-f577-c9f5-e917-f834b7e4b8d5@tarantool.org> Date: Tue, 16 Mar 2021 00:42:22 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D3134714A9BDB69B227B6855B2F1ABFAB31FADE3C60B02DF00894C459B0CD1B9EB8008FD4393DA835EEB31AF8802B39B83F0F5BDEF6490539799EF890AE2FEA9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76DA79C5AFF329FDBEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E8D1333770DC60CDEA1F7E6F0F101C67CDEEF6D7F21E0D1D174C73DBBBFC76640446816EBA6923B4D91A04C0FB4A1A74429F045DF87C369A389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D6FBC3EC642A93BBCC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC569F1129A2C6445075ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E735DC7F9DB2523BC7CDC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0FECB2555BB02FD5A93B503F486389A921A5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E923155C0AF1600DCBC20BC34632CCC2A66CABD121AC5E062942CA X-C1DE0DAB: 0D63561A33F958A56190FDDD3369C471E93CA79FFE8B48A2303BC9AA8F90FAB3D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A2EC120135420F90BF7C3EA9DA4F560077A34B7579806D6007B1084F30D108BBA06FEA8CDDED640C1D7E09C32AA3244C16673DCD46DD288A1E428F96C0CA29C3BBA718C7E6A9E042927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmD8gqPF9k0mjxBhDdmgW4A== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822A0A453D720C3E60602CE16FCCD2BB2113841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3] wal: introduce limits on simultaneous writes 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" Hi! Thanks for the patch! I must admit, it looks kind of ugly :D. The class we have now only remotely looks like a semaphore. Number of reasons, some of which you already listed in the header file: - It is advisory. Can be bypassed easily if you forget to check wouldblock. But not a big issue really. An optional thing like 'try_take' is needed for box.commit({is_async = true}) anyway, not to block the fiber; - You can take more amount of the resource than there is. Bearable as well, but still; - sem_release() does not wakeup anybody. Quite counter-intuitive; - The wouldblock check not only checks the resource being available, but also if there are any waiters. It wouldn't matter for a real semaphore, because it has nothing to do with ordering the waiters in FIFO. It is a detail of the journal which slipped into the general class. But maybe that is the only way to make it fair? Otherwise some fibers could be blocked forever due to starvation. The last thing I am not sure is even an issue. Might be a feature. The others probably can be fixed if we would rework journal_queue API. For instance, not have journal_queue_wait() separated from journal_queue_on_append(). Then sem_take() could become blocking and obligatory. You simply inline everything into journal_write() and journal_write_try_async(), and you will see that you can always call take() and block inside of it. But I don't know if it is worth doing TBH. It is used in a single place so far. This is hard to define fiber_sem API which would be suitable for future usages. I would vote for not doing it now and see if we would need the semaphore in the future. Although the idea about removing journal_queue_wait() might be worth trying. It is used either right before journal_queue_on_append(), or in journal_queue_flush() which is also right before journal_queue_on_append(). Up to you. Anyway we need to return to this code for box.commit({is_async}) feature, which means the hard polishing might be not so useful.