Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH v2 6/9] box: load persistent Lua functions on creation
Date: Mon, 10 Jun 2019 15:19:52 +0300	[thread overview]
Message-ID: <20190610121952.jmcqzt34mjv6hovx@esperanza> (raw)
In-Reply-To: <1711e6a83d3d3ca2895d932b3c82b24065b10f2d.1559822429.git.kshcherbatov@tarantool.org>

On Thu, Jun 06, 2019 at 03:04:02PM +0300, Kirill Shcherbatov wrote:
> This patch proceed persistent Lua function load on function
> object creation.
> 
> Part of #4182
> Needed for #1260
> ---
>  src/box/func.c                    |  77 +++++++++++++++--
>  src/box/func.h                    |  30 +++++--
>  src/box/func_def.h                |   6 ++
>  test/box/persistent_func.result   | 136 ++++++++++++++++++++++++++++++
>  test/box/persistent_func.test.lua |  61 ++++++++++++++
>  5 files changed, 292 insertions(+), 18 deletions(-)
>  create mode 100644 test/box/persistent_func.result
>  create mode 100644 test/box/persistent_func.test.lua
> 
> diff --git a/src/box/func.c b/src/box/func.c
> index 71c6bb6eb..b21221d9e 100644
> --- a/src/box/func.c
> +++ b/src/box/func.c
> @@ -438,6 +438,7 @@ func_new(struct func_def *def)
>  		 */
>  	} else {
>  		assert(def->language == FUNC_LANGUAGE_LUA);
> +		func->lua_ref = LUA_REFNIL;
>  		func->vtab = &func_lua_vtab;
>  	}
>  	return func;

I think we should check function code in the constructor - it's more
user-friendly than checking it on the first execution.

> @@ -627,7 +677,12 @@ func_lua_call(struct func *func, struct port *port, const char *args,
>  	assert(func != NULL && func->def->language == FUNC_LANGUAGE_LUA);
>  	assert(func->vtab == &func_lua_vtab);
>  
> +	if (func_def_is_persistent(func->def) && func->lua_ref == LUA_REFNIL &&
> +	    func_lua_load(func) != 0)
> +		return -1;
> +

Branching in a virtual method doesn't look good IMO. Why not add
a separate class for persistent Lua functions?

> diff --git a/src/box/func_def.h b/src/box/func_def.h
> index 7a920f65e..8953e4776 100644
> --- a/src/box/func_def.h
> +++ b/src/box/func_def.h
> @@ -89,6 +89,12 @@ func_def_sizeof(uint32_t name_len, uint32_t body_len)
>  	return sz;
>  }
>  
> +static inline bool
> +func_def_is_persistent(struct func_def *def)
> +{
> +	return def->body != NULL;
> +}
> +

Pointless helper IMO - it's okay to check 'body' directly in Lua
constructor.

  reply	other threads:[~2019-06-10 12:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 12:03 [PATCH v2 0/9] box: rework functions machinery Kirill Shcherbatov
2019-06-06 12:03 ` [PATCH v2 1/9] box: refactor box_lua_find helper Kirill Shcherbatov
2019-06-10  9:17   ` Vladimir Davydov
2019-06-06 12:03 ` [PATCH v2 2/9] box: move box_module_reload routine to func.c Kirill Shcherbatov
2019-06-10  9:19   ` Vladimir Davydov
2019-06-06 12:03 ` [PATCH v2 3/9] box: rework func cache update machinery Kirill Shcherbatov
2019-06-10  9:44   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 4/9] box: rework func object as a function frontend Kirill Shcherbatov
2019-06-10 10:32   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 5/9] schema: rework _func system space format Kirill Shcherbatov
2019-06-10 12:10   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 6/9] box: load persistent Lua functions on creation Kirill Shcherbatov
2019-06-10 12:19   ` Vladimir Davydov [this message]
2019-06-06 12:04 ` [PATCH v2 7/9] box: sandbox option for persistent functions Kirill Shcherbatov
2019-06-10 14:06   ` Vladimir Davydov
2019-06-10 14:15     ` [tarantool-patches] " Kirill Shcherbatov
2019-06-10 14:41       ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 8/9] box: implement lua_port dump to region and to Lua Kirill Shcherbatov
2019-06-10 14:24   ` Vladimir Davydov
2019-06-06 12:04 ` [PATCH v2 9/9] box: export _func functions with box.func folder Kirill Shcherbatov
2019-06-10 15:18   ` Vladimir Davydov
2019-06-10  9:14 ` [PATCH v2 0/9] box: rework functions machinery Vladimir Davydov

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=20190610121952.jmcqzt34mjv6hovx@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 6/9] box: load persistent Lua functions on creation' \
    /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