From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F3BD1469710 for ; Tue, 2 Jun 2020 12:45:46 +0300 (MSK) Date: Tue, 2 Jun 2020 12:36:39 +0300 From: Igor Munkin Message-ID: <20200602093639.GB5745@tarantool.org> References: <20200518093748.16825-1-skaplun@tarantool.org> <20200602001948.GA5745@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200602001948.GA5745@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] lua: lua_field_inspect_table without pushcfunction List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy OK, it was too late at night (or too early at morning), sorry. On 02.06.20, Igor Munkin wrote: > Sergey, > > Thanks for the patch! Please consider my comments below. > > On 18.05.20, Sergey Kaplun wrote: > > Currently on encoding table we push cfunction (lua_field_try_serialize) > > to lua stack with additional lightuserdata and table value and after > > pcall that function to avoid a raise of error. > > > > In this case LuaJIT creates new object which will not live long time, > > just assigns a pointer to the top guest stack > slot. Yes, it might trigger stack reallocation, but no GC object is > created. Yes creating a Lua function object with payload definitely clobbers GC. > > > Well, let's polish the commit message to make it a bit clearer. Commit > subject also looks non-informative and doesn't respect our contribution > guide[2], so I propose the following rewording: > | lua: remove excess Lua call from table encoding > | > | For safe table encoding function is pushed > | to Lua stack along with auxiliary lightuserdata and table object to be > | encoded. Its further protected call catches Lua error if one is raised > | while encoding. It is only necessary when the object to be serialized > | has __serialize field in metatable and this field is a Lua function. > | > | As a result of this change the function serializing the given object > | is called without excess protected frame and auxiliary status struct. Added this point to the last part: | This change reduces GC usage since a Lua function object is not | created. Moreover the function serializing the given object is called | without excess protected frame and auxiliary status struct. > Feel free to change it on your own. > > > -- > Best regards, > IM -- Best regards, IM