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 BCC6970310; Mon, 8 Feb 2021 14:54:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BCC6970310 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612785294; bh=ao0IrU+aIGocyWeStUq1OjB0ny4yIdjBetqPZxlp6IM=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dvVD5dZ8rYLBQ3hcHsngrun9IKjMxhbAT7kLmc0NcUgcPR222mtKN6QI9Q7Vs+rV5 E6zNqeTQ5u5SjwRlnzU9XgxCc9jGqzl9ztEt+Vp1aNkMRppp15dqNgWpqBQq/Sf4ry bHiACJLUOqW+ud7jhF23Q7rTG8HgY4cieIJ2GVkI= Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 3CD9670310 for ; Mon, 8 Feb 2021 14:54:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3CD9670310 Received: by mail-lj1-f181.google.com with SMTP id s18so16597396ljg.7 for ; Mon, 08 Feb 2021 03:54:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RafGcpp+hIHwzW79zg/x5f6YS1zXQh+4nzwMxuVeWSA=; b=TKxRPcXWs0rvjrytka4OEIAm0DFkjqWesWKjJWo+Qb68ndZRERhHgF65Egbn7uew7D MPsR43iRRfl/dEFYh8+4sptckkRIvWrES4vJ2nda4GAOfnCYtQRzsQzXtvepolmYs+TK 6zleEEhBK+9H5rzpOHLcgLiDelVNjFVPGB6Ud8MvEwGtLaJgQcCTK+XTb24zAqSky9jd szPDnIxkt/gN/jNotGMfpFMAVQIALkzHcEHXUMW45gSiRQvhjvcwExpRJWbICUQ5sSV/ /x3x74GG0JaocYd7U6HULGaiXVwKmMNSHlk5eefWORsJaB+c25RDGS+9kgqD2+tB8jon 3YpA== X-Gm-Message-State: AOAM533TttddfCq7FGb8+kJe5xxcou5kn8bI71wHAAy31I9LirlEiiCW JTtux+a+PbMsBowU/V55/iE= X-Google-Smtp-Source: ABdhPJzyg4t8l2YKOk65EyUS3gfxViLArha7X40IeDLNL8fs8WU7spMZZMBiSrofntwodMmzMqU5ug== X-Received: by 2002:a2e:8045:: with SMTP id p5mr10862408ljg.76.1612785292722; Mon, 08 Feb 2021 03:54:52 -0800 (PST) Received: from grain.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id d14sm2066939lfa.7.2021.02.08.03.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 03:54:51 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 53C2F5601BA; Mon, 8 Feb 2021 14:54:50 +0300 (MSK) Date: Mon, 8 Feb 2021 14:54:50 +0300 To: Vladislav Shpilevoy Cc: tml , Mons Anderson Message-ID: <20210208115450.GM2172@grain> References: <20210205185436.638894-1-gorcunov@gmail.com> <20210205185436.638894-8-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.14.6 (2020-07-11) Subject: Re: [Tarantool-patches] [PATCH v15 07/11] module_cache: use references as a main usage counter 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Sun, Feb 07, 2021 at 06:20:34PM +0100, Vladislav Shpilevoy wrote: > Thanks for the patch! > > See 2 comments below. > > > + > > +/** > > + * Decrease module reference and delete it if last one. > > + */ > > +static void > > +module_unref(struct module *module) > > +{ > > + assert(module->refs > 0); > > + if (module->refs-- == 1) { > > + if (!module_is_orphan(module)) { > > + size_t len = strlen(module->package); > > + module_cache_del(module->package, > > + &module->package[len]); > > 1. You can also compare pointer in the hash. If it matches - > delete it. Then you wouldn't need the orphan concept at all. This gonna be a way more longer than zapping slash. But if you prefer this way, sure thing. > > > > - module_gc(old); > > + module_set_orphan(old); > > + module_unref(old); > > + > > + /* From explicit load above */ > > + module_unref(new); > > 2. Where is the explicit ref? A couple of lines above struct module *new = module_load(package, package_end); if (new == NULL) return -1; The thing is that box.schema.func doesn't use module_load at all which takes first reference, instead it uses symols as an origin for counters, thus we need to decrease the conter here because when box.schema.func close last symbol nobody gonna call module_unload and module will hang in memory forever. Probably I should write more verbose comment here. Cyrill