From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Igor Munkin <imun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v2 3/3] lua: expose temporary Lua state for iproto calls
Date: Thu, 16 Jul 2020 23:11:37 +0300 [thread overview]
Message-ID: <20200716201137.3qvizw3mri64kayv@tkn_work_nb> (raw)
In-Reply-To: <20200701203706.GC5559@tarantool.org>
> > There is code that may save some time and resources for creating a new
> > Lua state when it is present in the fiber storage of a current fiber.
>
> Typo: s/present/presented/.
According to [1] the word may be considered as an adjective and so using
it as 'present' here is technically correct. This article gives the
following difference in meanging:
| "As presented" (verb) connotes deliberate placement. "As present"
| (adjective) just means it's there.
'It is there' is what I want to express here, so 'present' looks as the
better choice here.
Does not I miss something about grammar here?
[1]: https://www.instructionalsolutions.com/blog/bid/102954/Tables-in-Report-Writing-Presented-or-Present
> > This patch fills fiber->storage.lua.stack for background fibers that
> > serve a Lua call or eval: we already have this state and nothing prevent
>
> Typo: s/prevent/prevents/.
Thanks! Fixed.
> > diff --git a/src/box/lua/call.c b/src/box/lua/call.c
> > index 6588ec2fa..ccdef6662 100644
> > --- a/src/box/lua/call.c
> > +++ b/src/box/lua/call.c
> > @@ -537,12 +537,39 @@ box_process_lua(lua_CFunction handler, struct execute_lua_ctx *ctx,
> > port_lua_create(ret, L);
> > ((struct port_lua *) ret)->ref = coro_ref;
> >
> > + /*
> > + * A code that need a temporary fiber-local Lua state may
> > + * save some time and resources for creating a new state
> > + * and use this one.
> > + */
>
> Could you please provide an example for the fiber calling this function
> with non-NULL fiber-local Lua state?
Sure.
| tarantool> box.cfg{}
| tarantool> echo = function(...) return ... end
| tarantool> box.schema.func.create('echo')
| tarantool> box.schema.func.call('echo', {1, 2, 3})
I added the assert and verified it just in case:
| diff --git a/src/box/lua/call.c b/src/box/lua/call.c
| index 0315e720c..0221ffd2d 100644
| --- a/src/box/lua/call.c
| +++ b/src/box/lua/call.c
| @@ -561,6 +561,7 @@ box_process_lua(enum handlers handler, struct execute_lua_ctx *ctx,
| * and use this one.
| */
| bool has_lua_stack = fiber()->storage.lua.stack != NULL;
| + assert(fiber()->storage.lua.stack == NULL);
| if (!has_lua_stack)
| fiber()->storage.lua.stack = L;
The assert fails after the steps above.
(But even if it would not be possible, I would write the code this way
to don't lean on not-so-obvious details that may be changed in a
future.)
> Are those conditions below are strictly required by the current
> implementation?
When the fiber-local Lua state is present it should not be changed or
zapped by the function. I don't know whether it would lead to some
negative behaviour changes, but it would be at least counter-intuitive.
There is the comment on the topic (I left it cited below).
> > + * But: keep the stack if it was present before the call,
> > + * because it would be counter-intuitive if the existing
> > + * state pointer would be zapped after this function call.
> > + */
> > + if (!has_lua_stack)
> > + fiber()->storage.lua.stack = NULL;
BTW, 'present' is here again. Don't know what form is better here, but
left it as is now.
next prev parent reply other threads:[~2020-07-16 20:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 21:06 [Tarantool-patches] [PATCH v2 0/3] Merger's NULL defererence Alexander Turenko
2020-06-17 21:06 ` [Tarantool-patches] [PATCH v2 1/3] merger: fix NULL dereference when called via iproto Alexander Turenko
2020-06-18 22:48 ` Vladislav Shpilevoy
2020-06-19 8:50 ` Alexander Turenko
2020-06-19 23:32 ` Vladislav Shpilevoy
2020-06-21 18:28 ` Alexander Turenko
2020-07-01 20:36 ` Igor Munkin
2020-07-16 20:10 ` Alexander Turenko
2020-07-16 21:42 ` Igor Munkin
2020-07-16 22:44 ` Igor Munkin
2020-07-17 3:08 ` Alexander Turenko
2020-06-17 21:06 ` [Tarantool-patches] [PATCH v2 2/3] merger: clean fiber-local Lua stack after next() Alexander Turenko
2020-06-19 8:50 ` Alexander Turenko
2020-07-01 20:36 ` Igor Munkin
2020-07-16 20:11 ` Alexander Turenko
2020-07-16 22:07 ` Igor Munkin
2020-07-17 3:08 ` Alexander Turenko
2020-06-17 21:06 ` [Tarantool-patches] [PATCH v2 3/3] lua: expose temporary Lua state for iproto calls Alexander Turenko
2020-07-01 20:37 ` Igor Munkin
2020-07-16 20:11 ` Alexander Turenko [this message]
2020-07-16 22:33 ` Igor Munkin
2020-07-17 3:09 ` Alexander Turenko
2020-06-22 20:38 ` [Tarantool-patches] [PATCH v2 0/3] Merger's NULL defererence Vladislav Shpilevoy
2020-07-17 11:28 ` Alexander Turenko
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=20200716201137.3qvizw3mri64kayv@tkn_work_nb \
--to=alexander.turenko@tarantool.org \
--cc=imun@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 3/3] lua: expose temporary Lua state for iproto calls' \
/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