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 758CF1295911; Wed, 5 Mar 2025 13:48:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 758CF1295911 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1741171692; bh=H/zU9tE4ZBbkdShabI0wh/1D2vnna+SfcO0bxVDiq3Y=; 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=vXoMC8IlCryAVZ5tG8ia2QbzR5Sp6/ZiIkCLjDydrJ/HaFxTwCjcEWaepGg8RXXmH AZ5aFZiFmm/WX/KZuExdjmodjIJYEERaLZ96ghbVGJjMQ1EjzLtThMK1p7wqKO6E/j 22XHF0OE8Vfzr/zWo80kJf+7L8P+qwuDzuoR+cB4= Received: from send175.i.mail.ru (send175.i.mail.ru [95.163.59.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 1ADC11295913 for ; Wed, 5 Mar 2025 13:48:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1ADC11295913 Received: by exim-smtp-848fbd8fb5-wn287 with esmtpa (envelope-from ) id 1tpmIL-00000000CEx-3YB4; Wed, 05 Mar 2025 13:48:10 +0300 Content-Type: multipart/alternative; boundary="------------lcmkNkW2uOyk0LDU6mBgyI0N" Message-ID: <1874ff07-be1e-464f-94df-9464875b7739@tarantool.org> Date: Wed, 5 Mar 2025 13:48:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun Cc: Sergey Bronnikov , tarantool-patches@dev.tarantool.org References: <881980705ead69f58c0474d5f49c00603e4c6e72.1740050074.git.sergeyb@tarantool.org> <52e2b52f-33a8-4f06-bcd8-ec8aa9fc457a@tarantool.org> Content-Language: en-US In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9A2A28D6C22EE44037C590874E2EEE6C28EBE5CC7FABD3E68182A05F53808504013FAF7B16E07E31B3DE06ABAFEAF67058681B2FE60B50162E21EAD5E463A63D74C0C6A52ECAB1499 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE721B3E54BB37EA0B4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566AE3F01DD33DDBDC8DE45CD780A8788D3D842E5A2236F5915AE25A3C2D2BD812F389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0ECC8AC47CD0EDEFF8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B601F8F2FECC0250C8CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249C6B838B2E188F3DD76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B6CD59D4702E06C103AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7355705F49E3A860CEDC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A51FE869375E5B6EDB5002B1117B3ED6969452BC8AB0EC7335E41E333F9D1358D5823CB91A9FED034534781492E4B8EEAD5DF1C2DF01CE7211BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF9FB4C981735FFD3E3D647753E52374852867B976DEC9D49D9F6CC0A257074111284AB208DE0D1BB12C10F42E4F22A8B6A3184600C30A4A3C9AB1C283BA59D567D0BC1C329EBB1A0B5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVQiWK+2I7Y2scuLXolEzsXI= X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140DEB7C01238D080180578E6996F383413A3FD532E0DA25DB30152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 4/8][v3] sysprof: introduce specific errors and default mode 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: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------lcmkNkW2uOyk0LDU6mBgyI0N Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey! Changes applied and force-pushed. Sergey On 05.03.2025 10:55, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the fixes! > LGTM, after fixing 3 minor nits below. > > On 24.02.25, Sergey Bronnikov wrote: >> Hi, Sergey, >> >> changes applied and force-pushed. >> >> Sergey >> >> On 24.02.2025 15:46, Sergey Kaplun via Tarantool-patches wrote: >>> Hi, Sergey! >>> Thanks for the fixes! >>> LGTM, after the final polishing, please consider my comments below. >>> >>> On 20.02.25, Sergey Bronnikov wrote: > > >>>> --- >>>> src/lib_misc.c | 77 ++++++++++++------- >>>> src/lj_errmsg.h | 5 ++ >>>> .../profilers/misclib-sysprof-lapi.test.lua | 68 ++++++++++++++-- >>>> 3 files changed, 114 insertions(+), 36 deletions(-) >>>> >>>> diff --git a/src/lib_misc.c b/src/lib_misc.c >>>> index 5b7a4b62..1fd06dd1 100644 >>>> --- a/src/lib_misc.c >>>> +++ b/src/lib_misc.c >>>> @@ -14,6 +14,7 @@ >>>> >>>> #include "lj_obj.h" >>>> #include "lj_str.h" >>>> +#include "lj_strfmt.h" >>> Please add the corresponding include (after lj_str.h) in to >>> avoid conflicts when we use this file (for crossbuilds or whatever). > There is no corresponding update on the branch. Sorry, missed this comment. Fixed: --- a/src/Makefile.dep.original +++ b/src/Makefile.dep.original @@ -30,7 +30,7 @@ lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \  lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \   lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h  lib_misc.o: lib_misc.c lua.h luaconf.h lmisclib.h lauxlib.h lj_obj.h \ - lj_def.h lj_arch.h lj_str.h lj_tab.h lj_lib.h lj_gc.h lj_err.h \ + lj_def.h lj_arch.h lj_str.h lj_strfmt.h lj_tab.h lj_lib.h lj_gc.h lj_err.h \   lj_errmsg.h lj_memprof.h lj_wbuf.h lj_libdef.h  lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \   lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_lib.h \ > > > >>>> -static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, int idx) { >>>> - GCtab *options = lj_lib_checktab(L, idx); >>>> +static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, >>>> + const char **err_details) { >>> Nit: Please, replace every 8 spaces with one tab. >> Fixed: >> >> --- a/src/lib_misc.c >> +++ b/src/lib_misc.c >> @@ -180,7 +180,7 @@ static int set_output_path(const char *path, struct >> luam_Sysprof_Options *opt) { >>  } >> >>  static int parse_sysprof_opts(lua_State *L, struct >> luam_Sysprof_Options *opt, >> -                             const char **err_details) { >> +                             const char **err_details) { > Thanks! > Please apply the following patch. It fixes all patchset-related places. Applied. > > =================================================================== > diff --git a/src/lib_misc.c b/src/lib_misc.c > index 94ec6564..79cfaf7b 100644 > --- a/src/lib_misc.c > +++ b/src/lib_misc.c > @@ -199,13 +199,13 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, > cTValue *mode_opt = lj_tab_getstr(options, lj_str_newlit(L, "mode")); > if (mode_opt) { > if (!tvisstr(mode_opt)) { > - *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > - return PROFILE_ERRUSE; > + *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > + return PROFILE_ERRUSE; > } > mode = strVdata(mode_opt); > if (strlen(mode) == 0 || mode[1] != '\0') { > - *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > - return PROFILE_ERRUSE; > + *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > + return PROFILE_ERRUSE; > } > } > > @@ -223,8 +223,8 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, > opt->mode = LUAM_SYSPROF_CALLGRAPH; > break; > default: > - *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > - return PROFILE_ERRUSE; > + *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE); > + return PROFILE_ERRUSE; > } > } > > @@ -235,8 +235,8 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, > if (interval && tvisnumber(interval)) { > int32_t signed_interval = numberVint(interval); > if (signed_interval < 1) { > - *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADINTERVAL); > - return PROFILE_ERRUSE; > + *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADINTERVAL); > + return PROFILE_ERRUSE; > } > opt->interval = signed_interval; > } > @@ -281,9 +281,9 @@ static int sysprof_error(lua_State *L, int status, const char *err_details) > case PROFILE_ERRUSE: > lua_pushnil(L); > if (err_details) > - lj_strfmt_pushf(L, "%s: %s", err2msg(LJ_ERR_PROF_MISUSE), err_details); > + lj_strfmt_pushf(L, "%s: %s", err2msg(LJ_ERR_PROF_MISUSE), err_details); > else > - lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE)); > + lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE)); > lua_pushinteger(L, EINVAL); > return 3; > #if LJ_HASSYSPROF > =================================================================== > >>    int n = (int)(L->top - L->base); > > >>>> +test:is(res, false, "res with not a table") >>>> +test:ok(err:match("table expected, got string"), >>>> + "error with not a table") >>>> +test:is(errno, nil, "errno with not a table") >>> There is no need to check or declare the `errno` variable. It's always >>> `nil` for the case when the error is raised. >> The check is cheap, why not? > This is kind of misleading, plus this is a dead check. It is __always__ > `nil`, or we will get an error in the first test and the second test. > Since we are not testing `pcall()` implementation here, let's just drop > it (it is even cheaper :)). okay, removed: @@ -85,11 +85,10 @@ test:ok(ok == false and err_msg:match("cannot open a file"),  assert(misc.sysprof.stop())  -- Not a table. -res, err, errno = pcall(misc.sysprof.start, "NOT A TABLE") +res, err = pcall(misc.sysprof.start, "NOT A TABLE") test:is(res, false, "res with not a table") test:ok(err:match("table expected, got string"),          "error with not a table") -test:is(errno, nil, "errno with not a table")  -- All parameters are invalid. Check parameter validation order  -- (not strict documented behaviour). > > > --------------lcmkNkW2uOyk0LDU6mBgyI0N Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey!

Changes applied and force-pushed.

Sergey

On 05.03.2025 10:55, Sergey Kaplun wrote:
Hi, Sergey!
Thanks for the fixes!
LGTM, after fixing 3 minor nits below.

On 24.02.25, Sergey Bronnikov wrote:
Hi, Sergey,

changes applied and force-pushed.

Sergey

On 24.02.2025 15:46, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the fixes!
LGTM, after the final polishing, please consider my comments below.

On 20.02.25, Sergey Bronnikov wrote:
<snipped>

---
  src/lib_misc.c                                | 77 ++++++++++++-------
  src/lj_errmsg.h                               |  5 ++
  .../profilers/misclib-sysprof-lapi.test.lua   | 68 ++++++++++++++--
  3 files changed, 114 insertions(+), 36 deletions(-)

diff --git a/src/lib_misc.c b/src/lib_misc.c
index 5b7a4b62..1fd06dd1 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -14,6 +14,7 @@
  
  #include "lj_obj.h"
  #include "lj_str.h"
+#include "lj_strfmt.h"
Please add the corresponding include (after lj_str.h) in <src/Makefile.dep.original> to
avoid conflicts when we use this file (for crossbuilds or whatever).
There is no corresponding update on the branch.

Sorry, missed this comment.

Fixed:

--- a/src/Makefile.dep.original
+++ b/src/Makefile.dep.original
@@ -30,7 +30,7 @@ lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
 lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
  lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h
 lib_misc.o: lib_misc.c lua.h luaconf.h lmisclib.h lauxlib.h lj_obj.h \
- lj_def.h lj_arch.h lj_str.h lj_tab.h lj_lib.h lj_gc.h lj_err.h \
+ lj_def.h lj_arch.h lj_str.h lj_strfmt.h lj_tab.h lj_lib.h lj_gc.h lj_err.h \
  lj_errmsg.h lj_memprof.h lj_wbuf.h lj_libdef.h
 lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
  lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_lib.h \



        
<snipped>

-static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt, int idx) {
-  GCtab *options = lj_lib_checktab(L, idx);
+static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt,
+	                      const char **err_details) {
Nit: Please, replace every 8 spaces with one tab.
Fixed:

--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -180,7 +180,7 @@ static int set_output_path(const char *path, struct 
luam_Sysprof_Options *opt) {
  }

  static int parse_sysprof_opts(lua_State *L, struct 
luam_Sysprof_Options *opt,
-                             const char **err_details) {
+                             const char **err_details) {
Thanks!
Please apply the following patch. It fixes all patchset-related places.
Applied.

===================================================================
diff --git a/src/lib_misc.c b/src/lib_misc.c
index 94ec6564..79cfaf7b 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -199,13 +199,13 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt,
     cTValue *mode_opt = lj_tab_getstr(options, lj_str_newlit(L, "mode"));
     if (mode_opt) {
       if (!tvisstr(mode_opt)) {
-        *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
-        return PROFILE_ERRUSE;
+	*err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
+	return PROFILE_ERRUSE;
       }
       mode = strVdata(mode_opt);
       if (strlen(mode) == 0 || mode[1] != '\0') {
-        *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
-        return PROFILE_ERRUSE;
+	*err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
+	return PROFILE_ERRUSE;
       }
     }
 
@@ -223,8 +223,8 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt,
         opt->mode = LUAM_SYSPROF_CALLGRAPH;
         break;
       default:
-        *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
-        return PROFILE_ERRUSE;
+	*err_details = err2msg(LJ_ERR_PROF_DETAILS_BADMODE);
+	return PROFILE_ERRUSE;
     }
   }
 
@@ -235,8 +235,8 @@ static int parse_sysprof_opts(lua_State *L, struct luam_Sysprof_Options *opt,
     if (interval && tvisnumber(interval)) {
       int32_t signed_interval = numberVint(interval);
       if (signed_interval < 1) {
-        *err_details = err2msg(LJ_ERR_PROF_DETAILS_BADINTERVAL);
-        return PROFILE_ERRUSE;
+	*err_details = err2msg(LJ_ERR_PROF_DETAILS_BADINTERVAL);
+	return PROFILE_ERRUSE;
       }
       opt->interval = signed_interval;
     }
@@ -281,9 +281,9 @@ static int sysprof_error(lua_State *L, int status, const char *err_details)
     case PROFILE_ERRUSE:
       lua_pushnil(L);
       if (err_details)
-        lj_strfmt_pushf(L, "%s: %s", err2msg(LJ_ERR_PROF_MISUSE), err_details);
+	lj_strfmt_pushf(L, "%s: %s", err2msg(LJ_ERR_PROF_MISUSE), err_details);
       else
-        lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE));
+	lua_pushstring(L, err2msg(LJ_ERR_PROF_MISUSE));
       lua_pushinteger(L, EINVAL);
       return 3;
 #if LJ_HASSYSPROF
===================================================================

    int n = (int)(L->top - L->base);
<snipped>

+test:is(res, false, "res with not a table")
+test:ok(err:match("table expected, got string"),
+        "error with not a table")
+test:is(errno, nil, "errno with not a table")
There is no need to check or declare the `errno` variable. It's always
`nil` for the case when the error is raised.
The check is cheap, why not?
This is kind of misleading, plus this is a dead check. It is __always__
`nil`, or we will get an error in the first test and the second test.
Since we are not testing `pcall()` implementation here, let's just drop
it (it is even cheaper :)).

okay, removed:

@@ -85,11 +85,10 @@ test:ok(ok == false and err_msg:match("cannot open a file"),
 assert(misc.sysprof.stop())
 
 -- Not a table.
-res, err, errno = pcall(misc.sysprof.start, "NOT A TABLE")
+res, err = pcall(misc.sysprof.start, "NOT A TABLE")
 test:is(res, false, "res with not a table")
 test:ok(err:match("table expected, got string"),
         "error with not a table")
-test:is(errno, nil, "errno with not a table")
 
 -- All parameters are invalid. Check parameter validation order
 -- (not strict documented behaviour).



<snipped>

--------------lcmkNkW2uOyk0LDU6mBgyI0N--