From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, imun@tarantool.org,
korablev@tarantool.org
Subject: [Tarantool-patches] [PATCH v2 3/3] swim: use fiber._internal.schedule_task() for GC
Date: Tue, 3 Mar 2020 00:29:53 +0100 [thread overview]
Message-ID: <189a6d9e98ba6a3fa03cf0b544dd7b7e06892395.1583191602.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1583191602.git.v.shpilevoy@tarantool.org>
swim object created a new fiber in its GC function, because C
function swim_delete() yields, and can't be called from an ffi.gc
hook.
It is not needed since the fiber module has a single worker
exactly for such cases. The patch uses it.
Follow up #4727
---
src/lua/swim.lua | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/lua/swim.lua b/src/lua/swim.lua
index 01eeb7eae..0859915c9 100644
--- a/src/lua/swim.lua
+++ b/src/lua/swim.lua
@@ -5,6 +5,7 @@ local msgpack = require('msgpack')
local crypto = require('crypto')
local fiber = require('fiber')
local internal = require('swim')
+local schedule_task = fiber._internal.schedule_task
ffi.cdef[[
struct swim;
@@ -954,14 +955,12 @@ local cache_table_mt = { __mode = 'v' }
-- instance immediately, because it is invoked by Lua GC. Firstly,
-- it is not safe to yield in FFI - Jit can't survive a yield.
-- Secondly, it is not safe to yield in any GC function, because
--- it stops garbage collection. Instead, here a new fiber is
--- created without yields, which works at the end of the event
--- loop, and deletes the instance asynchronously.
+-- it stops garbage collection. Instead, here GC is delayed, works
+-- at the end of the event loop, and deletes the instance
+-- asynchronously.
--
local function swim_gc(ptr)
- fiber.new(function()
- internal.swim_delete(ptr)
- end)
+ schedule_task(internal.swim_delete, ptr)
end
--
--
2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-03-02 23:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 23:29 [Tarantool-patches] [PATCH v2 0/3] fio: close unused descriptors automatically Vladislav Shpilevoy
2020-03-02 23:29 ` [Tarantool-patches] [PATCH v2 1/3] fiber: introduce schedule_task() internal function Vladislav Shpilevoy
2020-03-19 14:52 ` Igor Munkin
2020-03-20 0:00 ` Vladislav Shpilevoy
2020-03-20 10:48 ` Igor Munkin
2020-03-02 23:29 ` [Tarantool-patches] [PATCH v2 2/3] fio: close unused descriptors automatically Vladislav Shpilevoy
2020-03-19 14:53 ` Igor Munkin
2020-03-19 22:53 ` Igor Munkin
2020-03-20 0:00 ` Vladislav Shpilevoy
2020-03-20 10:48 ` Igor Munkin
2020-03-20 21:28 ` Vladislav Shpilevoy
2020-03-20 21:28 ` Igor Munkin
2020-03-02 23:29 ` Vladislav Shpilevoy [this message]
2020-03-19 14:53 ` [Tarantool-patches] [PATCH v2 3/3] swim: use fiber._internal.schedule_task() for GC Igor Munkin
2020-03-26 1:08 ` [Tarantool-patches] [PATCH v2 0/3] fio: close unused descriptors automatically Nikita Pettik
2020-03-26 12:56 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=189a6d9e98ba6a3fa03cf0b544dd7b7e06892395.1583191602.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=imun@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 3/3] swim: use fiber._internal.schedule_task() for GC' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox