From: Igor Munkin <imun@tarantool.org> To: Olga Arkhangelskaia <arkholga@tarantool.org>, s@tarantool.org Cc: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org Subject: Re: [Tarantool-patches] [PATCH 0/1] fix box.info:memory() Date: Thu, 2 Jul 2020 00:34:41 +0300 [thread overview] Message-ID: <20200701213441.GD5559@tarantool.org> (raw) In-Reply-To: <20200629121118.21596-1-arkholga@tarantool.org> Olya, Thanks for the patch! On 29.06.20, Olga Arkhangelskaia wrote: > The patch fixes the output of box.info:memory(). It used to return the same > table as the box.info(). > > box.info.memory() can be written as box.info[“memory”](), that later has the only > one argument on the stack - box.info.memory table we need to fill: > box.info.memory() -> getmetatable(box.info.memory).__call(box.info.memory)[1] > box.info:memory() call is the same as box.info[“memory”](box.info). So, it > results in extra argument on the stack[1]. > box.info:mem()->getmetatable(box.info.memory).__call(box.info.memory, box.info). > When function tries to fill box.info table - __call metamethod of box.info is > trigged - resulting in box.info table returned as the result. Nice passage! I guess it should be polished an added to the original commit message. > > There are two options to get rid if extra box.info table: > 1. Create new table in the beginning of the function(eg. box.info.gc). > Every time box.info.memory is called it will generate new table with the fresh > info. > 2. The second way is to ignore box.info argument on the stack and fill > directly box.info.memory table, that was passed as an argument. > > I have implemented the first approach because there is box.info.gc works > the same way and we only need to add one line of code. > However, I do not know why it was done in such a way on the first place. > So if you have pros for the second options, please share with me. I have no idea why it is implemented in such complex way, maybe Sasha does? Why box.info.memory yields an empty "callable" table on each lookup? Why it can't just return a function to be called or a table with memory metrics as a result of the lookup? Unfortunately the latter approach breaks the backward compatibility but the first one can save some time on short-term objects creation (I guess no one checks box.info.memory type). Thoughts? Please also consider the comments I left for the patch itself. > > [1] https://www.lua.org/manual/5.1/manual.html#2.8 > > @Changelog: > To retrieve information about memory usage box.info:memory() can be used. > Olga Arkhangelskaia (1): > box: fixed box.info:memory() > > src/box/lua/info.c | 1 + > test/box-tap/gh-4668-box-info-memory.test.lua | 15 +++++++++++++++ > 2 files changed, 16 insertions(+) > create mode 100755 test/box-tap/gh-4668-box-info-memory.test.lua > > -- > 2.20.1 (Apple Git-117) > -- Best regards, IM
next prev parent reply other threads:[~2020-07-01 21:44 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20200629121118.21596-1-arkholga@tarantool.org> 2020-06-29 12:11 ` [Tarantool-patches] [PATCH 1/1] box: fixed box.info:memory() Olga Arkhangelskaia 2020-07-01 21:34 ` Igor Munkin 2020-07-02 10:01 ` Olga Arkhangelskaia 2020-07-09 1:08 ` Alexander Turenko 2020-07-09 13:57 ` Olga Arkhangelskaia 2020-07-15 14:40 ` Alexander Turenko 2020-07-16 17:56 ` Igor Munkin 2020-07-16 20:29 ` Olga Arkhangelskaia 2020-07-16 20:56 ` Alexander Turenko 2020-07-16 21:04 ` Igor Munkin 2020-07-17 6:38 ` Olga Arkhangelskaia 2020-07-01 21:34 ` Igor Munkin [this message] 2020-07-09 1:08 ` [Tarantool-patches] [PATCH 0/1] fix box.info:memory() Alexander Turenko 2020-07-09 14:02 ` Olga Arkhangelskaia 2020-07-16 18:16 ` Igor Munkin 2020-07-16 18:29 ` Alexander Turenko 2020-07-17 6:18 ` Kirill Yukhin
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=20200701213441.GD5559@tarantool.org \ --to=imun@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=arkholga@tarantool.org \ --cc=s@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 0/1] fix box.info:memory()' \ /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