From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D5F0470358; Wed, 3 Feb 2021 01:12:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D5F0470358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612303933; bh=gO691gVwDQDAugmjkD7chdWmvRPBXXP6ZrYuY77Abfc=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=b6fzFDpebAY942Ly/x4xabLPH79sPyIOBxSh4TSJO+8n2LvdJ0E80r6J5jJQcEkTx oeAOiwJQ9dBZ4HdZxqr6O+1hW/nebFL5rIN0vDbpKVt1obroozPm+89+MFz8NL2tz+ Pk/FPKcj2Wc0eiCktEUwJtHlA5YqHdulLWmv4Huc= Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C405970358 for ; Wed, 3 Feb 2021 01:12:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C405970358 Received: by mail-lf1-f49.google.com with SMTP id e15so10191031lft.13 for ; Tue, 02 Feb 2021 14:12:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eqVC4Qd0UpLen/x3k54i16XKc1GKnx6XomCFJUCeYFE=; b=qE3IZV7ZOdYVm/z1ozlAp0A2woLGG4d6vrJbESiBe5X6gVZ0y78acr0FWA9e0FwJIe 6+sEc0Ngo/049aR+ZRWzlcMvHmlEBRVkNmPlWgnbDgT8fs+eEkRbNSIh2mB7UzeU9KIY Yky35pI5O5F0xbTC5tHrwfXt2oX1cIybfzr1Q2fltNiU4+mw2wy0q/ANcEHLGLgTv7jg qhdTqGhq2gxuWMR2E8IpmR4j9/3GKBz4edbkqXiwIRUSIWB86rpPzxdmTZHIHr8mQY6H hl3riysje3Le9YyFFL/Cas3xOW337aY5u2sKal6SMaLwOxPWuna9Yr7ZWo4DUEEB/9O1 gHPQ== X-Gm-Message-State: AOAM531NCfvvHQ0XfNiFERIxsh+t6KyzJkLZTFkrP7uco7Xcdz/Fd5pR x0ptl8342zQGCNDeNxCl77ryJwpM7pk= X-Google-Smtp-Source: ABdhPJx2WhIVF0KQJriP1ZpcLm71xA7pWfHDZX+yQg4Fs+lAAB1Nh43ulvovMbZTxBm2FjxmYPXCQw== X-Received: by 2002:a19:c89:: with SMTP id 131mr35513lfm.584.1612303931492; Tue, 02 Feb 2021 14:12:11 -0800 (PST) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id x29sm28351lfn.246.2021.02.02.14.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 14:12:09 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 82A655601DA; Wed, 3 Feb 2021 01:12:08 +0300 (MSK) To: tml Date: Wed, 3 Feb 2021 01:11:55 +0300 Message-Id: <20210202221207.383101-1-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v14 00/12] box: implement cmod Lua module X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The series implements a bare minimum. Vlad, please take a look once time permit. 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 branch gorcunov/gh-4642-func-ro-14 issue https://github.com/tarantool/tarantool/issues/4642 Cyrill Gorcunov (12): box/func: factor out c function entry structure module_cache: move module handling into own subsystem module_cache: direct update a cache value on reload module_cache: rename calls to ref in module structure module_cache: add comment about weird resolving module_cache: module_reload - drop redundant parameter module_cache: use references as a main usage counter module_cache: make module to carry hash it belongs to module_cache: use own hash for box.schema.func requests module_cache: provide module_load/unload calls box/cmod: implement cmod Lua module test: box/cfunc -- add cmod test src/box/CMakeLists.txt | 2 + src/box/call.c | 10 +- src/box/func.c | 491 +------------------------- src/box/func.h | 41 +-- src/box/func_def.h | 14 - src/box/lua/cmod.c | 600 +++++++++++++++++++++++++++++++ src/box/lua/cmod.h | 24 ++ src/box/lua/init.c | 2 + src/box/module_cache.c | 758 ++++++++++++++++++++++++++++++++++++++++ src/box/module_cache.h | 169 +++++++++ test/box/CMakeLists.txt | 2 + test/box/cfunc1.c | 58 +++ test/box/cfunc2.c | 137 ++++++++ test/box/cmod.result | 312 +++++++++++++++++ test/box/cmod.test.lua | 123 +++++++ test/box/suite.ini | 2 +- 16 files changed, 2200 insertions(+), 545 deletions(-) create mode 100644 src/box/lua/cmod.c create mode 100644 src/box/lua/cmod.h create mode 100644 src/box/module_cache.c create mode 100644 src/box/module_cache.h create mode 100644 test/box/cfunc1.c create mode 100644 test/box/cfunc2.c create mode 100644 test/box/cmod.result create mode 100644 test/box/cmod.test.lua base-commit: 7722a81c6a5a3c57c27a688c957fb187d81850f0 -- 2.29.2