[Tarantool-patches] [PATCH v21 0/6] box: implement box.lib Lua module
Kirill Yukhin
kyukhin at tarantool.org
Wed Apr 14 11:07:32 MSK 2021
Hello,
On 08 апр 19:41, Cyrill Gorcunov wrote:
> v1-v3 are development ones and not sent.
>
> v5 (by vlad):
> - drop exists, list methods: they are redundant
> - rename cfunc to cbox
> - when create a function make it callable Lua object
> - initialize cbox out of modules
> - fix error in passing module name for reloading
> - make api been cbox.func.[create|drop] and
> cbox.module.reload
> - fix test for OSX sake
>
> v6 (by vlad):
> - move module handling into module_cache file.
> v7:
> - development
> v8:
> - use rbtree for function instance storage, since
> i don't like the idea of unexpected rehashing of
> values in case of massive number of functions
> allocated
> - use reference counter and free function instance
> if only load/unload are coupled
> - keep a pointer to the function inside Lua object
> so we don't need to lookup on every function call.
> this force us to implement __gc method
> - use new API and update docs
> v9:
> - development
> v10:
> - use hashes for function names lookup
> - simply function loads counting
> - use luaL_register_module and luaL_register_type for
> easier methods registering
> - carry functions as userdata object
> v11:
> - development
> v12:
> - switch to new API as been discussed in
> https://lists.tarantool.org/tarantool-patches/e186c454-6765-4776-6433-f3f791ff4c27@tarantool.org/
> v13:
> - development
> v14:
> - switch to refs to carry module usage
> - drop func_name structure renaming
> - carry two hashes for backward compatibility with
> functions created via box.schema.func help
> - complete rework of cmod and most parts of
> module_cache
> - account for file statistics to invalidate
> module cache
> - new API for cmod, no more :reload, the :load
> procedure uses cache invalidation
> - update test cases
> - still there is no GC test since I didn't
> manage to deal with it
> v15:
> - report module state cached/orphan
> - update test cases
> - do not prevent functions lookup in orphan modules
> - there was an idea to use box.shema.func cache as on
> top of cmod's one, but this doesn't work because in case
> if module doesnt exist in any caches we would put it into
> into cmod's one as well but there wont be a module on
> cmod level which would clean it up later (which makes
> code a way more comple if we choose to track state
> of modules).
> v16:
> - internal
> v17:
> - drop idea of unifying box.schema.func and cmod functions
> cache, it brings more problems than solves due to too
> different context of execution;
> - make cmod self consistent, which shrink patch series
> size ~1/5 in compare with previous attempts;
> - improve tests to account internal states of modules
> and functions (tt_dev key in reports).
> v18:
> - implement pass-through cache for modules loading, for
> this sake 'struct module' uses cmod internally;
> - improve tests to cover sole cmod case and a mixture
> of box.schema.func and cmod to make sure the caches
> are not corrupted.
>
> v19:
> - move module handling into separate subsystem;
> - switch box.schema.func and cmod to use this shared
> code to eliminate code duplication;
> - update tests.
>
> v20:
> - fix potential nil dereference in schema_init while I'm in the code;
> - during working on the series found a bug in module recovery,
> fixed it in the series because my further work depends on it;
> - main module which allows to create C functions now named as box.lib;
> - structures renaming:
> - box.schema.func uses struct schema_module to carry underlied
> struct module;
> - box.lib uses struct module directly and struct box_module_func
> to carry cache of functions.
> - name unification:
> - schema_module variables are named as `mod`;
> - box.schema.func api prefixed as `schema_module_x`;
> - debug properties for module counting prefixed as `debug_x`;
> - the test remains disabled because
> - I run it locally all the time
> - better to have it in repo and enable then since patching
> test-run can take weeks, it is slow procedure
> v21:
> - rename functions and members from Vlad's comments
> - use @base name for lowlevel module and functions
> - use @module name for toplevel instances
> - rename __schema_module_load to schema_do_module_load
> - rename schema_func_c_load to func_c_load_from
> - rename box_lib.[ch] to plain lib.[ch]
> - cache free methods only clear the hash table itself
> - in cache_put make sure there is an empty slot we're touching
> - unify `const char *` usage
> - use lua_isstring instead of LUA_TSTRING test
> - optimize clearing of user data on Lua level via clear_udata
> helper
> - don't use tt_static hepers
> - in schema_module_reload restore failing function immediately
> and the proceed the remaining ones
> - move ERRINJ_DYN_MODULE_COUNT to module_cache so that
> old tests are passing
> - more detailed testing of module loading
> - make box.lib enabled by default even without box.cfg{}
>
> I pushed it and since github actions are not that fast I ran
> tests locally as well
>
> Statistics:
> * pass: 1250
> * disabled: 70
>
> issue https://github.com/tarantool/tarantool/issues/4642
> branch gorcunov/gh-4642-func-ro-21
I've checked your patch set into master.
--
Regards, Kirill Yukhin
More information about the Tarantool-patches
mailing list