From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (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 2344046970E for ; Mon, 10 Feb 2020 22:36:58 +0300 (MSK) References: <4600369.31r3eYUQgx@localhost> From: Vladislav Shpilevoy Message-ID: <57757b6b-559a-f330-e7c9-7d8e99161533@tarantool.org> Date: Mon, 10 Feb 2020 20:36:55 +0100 MIME-Version: 1.0 In-Reply-To: <4600369.31r3eYUQgx@localhost> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 1/1] fio: close unused descriptors automatically List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Georgy Kirichenko , tarantool-patches@dev.tarantool.org, korablev@tarantool.org, imun@tarantool.org Hi! Thanks for your review! On 09/02/2020 19:34, Georgy Kirichenko wrote: > Hi, thanks for the patch. > > Unfortunately your patch is not correct because fiber.create > yields (which could be fixed by using fiber.new) and raises an error what is not > allowed inside gc callbacks. Good catch! ================================================================================ -- FFI GC can't yield. Internal.close() yields. -- Collect the garbage later, in a separate fiber. - fiber.create(internal.close, fh) + fiber.new(internal.close, fh) end) }, fio_mt) ================================================================================ > From my point of view the possible approach is a dedicated fiber with > a list of pending callbacks. Yes, I was thinking about this as well, but thought it would be an overkill just for fio. Since you also propose this solution, I suggest to do it separately, and for other modules too. We could introduce a new module 'background', or 'gc', or 'worker', or 'pool' which would provide API like 'execute(func, arg)'. And it would call it in a special global fiber. Example: pool = require('pool') pool.execute(internal.close, fd) So basically we could reinvent fiber pool for Lua. This can be used for fio and SWIM objects GC, because SWIM currently also creates a new fiber in its GC callback. Also this could be implemented as a submodule of fiber module. For instance, fiber.pool.execute().