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 EC32257B70D; Wed, 19 Feb 2025 18:56:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EC32257B70D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1739980600; bh=uPWeZZmVk8mWYsBlZLvp0H8VZ2GkVTIISivqPQrGcTs=; 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=hBFV3x/wb3mezhJ8m8+NAhUw2YBI5aaVeNiPv3LlDAK0IuYle2F5ckzYeWkaesCY2 qNfkr41cTNARoGtuVu3RLJll1jZfOYwLaV1vljKxyuUFnCl0BYwIhsLMK2DSRz7lK3 mOg7oxz8rqHDMD3XD1hFoK8/PqJvyd6p4kWg0vBw= Received: from send57.i.mail.ru (send57.i.mail.ru [89.221.237.152]) (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 CFC7157B70D for ; Wed, 19 Feb 2025 18:56:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CFC7157B70D Received: by exim-smtp-5f589487f8-gpd2k with esmtpa (envelope-from ) id 1tkmRB-00000000OEL-3sYx; Wed, 19 Feb 2025 18:56:38 +0300 Content-Type: multipart/alternative; boundary="------------hEYLkUNamhL1wyiKWb9g0fXH" Message-ID: <9379873d-b24e-46dc-be53-0cf92f0ee170@tarantool.org> Date: Wed, 19 Feb 2025 18:56:37 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: Sergey Bronnikov , tarantool-patches@dev.tarantool.org References: <7f83ca101b76bba7b5789a6c5a7e9acb8044fed1.1739444510.git.sergeyb@tarantool.org> <73448ddd-5b78-4e89-a45b-0407fca1396f@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD916C41472748AFA04D4023FF5449FC6F0DDC9B7C52A85C5CD00894C459B0CD1B9A27BE0DC610B619205B18F8CB88C7B498DFEB447EF51BC88A21228CA24FF00D31BB59B39F4C00062 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B9D6DADD6B53929DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B23888C9749F3CAC8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DF4CFDA0896D04BD3C6DB7101CA0FEA29141861CC8BB44B2CC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C4E7D9683544204AF6E0066C2D8992A164AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3B74263D4D5690889BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE75B51C8FB0C3E748C731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5DF19456406C9B9435002B1117B3ED696F64BB14BDE24798E4A0A47EBA01A636A823CB91A9FED034534781492E4B8EEADC24E78AA85F86F6CBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF66C0586FBA022FE5EC6166B55F4EA79BD77B2D7C8A65CDAB0FD09FDCD0D41689265F63FF884E79B30526A8B1FD8BF66BB8C32807432645DB6795E6FADC1ACB1DF8A3998FC61D16675F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVWiyXSWEEqdr78Bl93R+rS8= X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140A27BE0DC610B619205B18F8CB88C7B497D3F36D30AAB4D3D0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 6/7] misc: specific message for disabled profilers 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. --------------hEYLkUNamhL1wyiKWb9g0fXH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, On 19.02.2025 18:41, Sergey Kaplun wrote: > Hi, Sergey! > Thanks for the fixes! > > On 19.02.25, Sergey Bronnikov wrote: >> Hi, Sergey, >> >> thanks for review! >> >> On 19.02.2025 11:06, Sergey Kaplun via Tarantool-patches wrote: > > >>> It's more LuaJIT-way to use something like the following: >>> | if (!LJ_HASSYSPROF) { >>> | /* ... */ >>> | } >>> >>> This helps to avoid strange early return. >> Fixed. >>> Also, please be avaired to declare all variables (stataus, opt, >>> err_details) in the beginning of the block. >>  It is a requirement for the code that strictly follows c89, when you >> must declare all of your variables at the beginning of a scope block. >> >> AFAIK, we have no such requirement, and also there is no option >> "-std=c89" in CI and no any mentions in the contribution guide. > This is not mentioned in Tarantool's contribution guide, since it is > LuaJIT-specific. In the perfect world, it should be checked by the flags > mentioned in (see the second CWARN). > Unfortunately, there are some bugs that should be fixed first. > > Fixed: diff --git a/src/lib_misc.c b/src/lib_misc.c index aaf08718..7b934e52 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -312,15 +312,14 @@ static int sysprof_error(lua_State *L, int status, const char *err_details)  LJLIB_CF(misc_sysprof_start)  {    const char *err_details = NULL; +  int status = PROFILE_SUCCESS; +  struct luam_Sysprof_Options opt = {}; +    if (!LJ_HASSYSPROF) {      err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);      return sysprof_error(L, PROFILE_ERRUSE, err_details);    } -  int status = PROFILE_SUCCESS; - -  struct luam_Sysprof_Options opt = {}; -    status = parse_sysprof_opts(L, &opt, &err_details);    if (LJ_UNLIKELY(status != PROFILE_SUCCESS))      return sysprof_error(L, status, err_details); @@ -337,11 +336,11 @@ LJLIB_CF(misc_sysprof_start)  /* local res, err, errno = profile.sysprof_stop() */  LJLIB_CF(misc_sysprof_stop)  { +  int status = luaM_sysprof_stop(L);    if (!LJ_HASSYSPROF) {      const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);      return sysprof_error(L, PROFILE_ERRUSE, err_details);    } -  int status = luaM_sysprof_stop(L);    if (LJ_UNLIKELY(status != PROFILE_SUCCESS))      return sysprof_error(L, status, NULL); @@ -352,15 +351,15 @@ LJLIB_CF(misc_sysprof_stop)  /* local counters, err, errno = sysprof.report() */  LJLIB_CF(misc_sysprof_report)  { +  struct luam_Sysprof_Counters counters = {}; +  GCtab *data_tab = NULL; +  GCtab *count_tab = NULL; +  int status = luaM_sysprof_report(&counters);    if (!LJ_HASSYSPROF) {      const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);      return sysprof_error(L, PROFILE_ERRUSE, err_details);    } -  struct luam_Sysprof_Counters counters = {}; -  GCtab *data_tab = NULL; -  GCtab *count_tab = NULL; -  int status = luaM_sysprof_report(&counters);    if (status != PROFILE_SUCCESS)      return sysprof_error(L, status, NULL); @@ -395,14 +394,14 @@ LJLIB_CF(misc_sysprof_report)  /* local started, err, errno = misc.memprof.start(fname) */  LJLIB_CF(misc_memprof_start)  { -  if (!LJ_HASMEMPROF) { -    const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED); -    return sysprof_error(L, PROFILE_ERRUSE, err_details); -  }    struct lj_memprof_options opt = {0};    const char *fname = strdata(lj_lib_checkstr(L, 1));    struct profile_ctx *ctx;    int memprof_status; +  if (!LJ_HASMEMPROF) { +    const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED); +    return sysprof_error(L, PROFILE_ERRUSE, err_details); +  }    /*    ** FIXME: more elegant solution with ctx. @@ -453,11 +452,11 @@ LJLIB_CF(misc_memprof_start)  /* local stopped, err, errno = misc.memprof.stop() */  LJLIB_CF(misc_memprof_stop)  { +  int status = lj_memprof_stop(L);    if (!LJ_HASMEMPROF) {      const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);      return sysprof_error(L, PROFILE_ERRUSE, err_details);    } -  int status = lj_memprof_stop(L);    if (status != PROFILE_SUCCESS) {      switch (status) {      case PROFILE_ERRUSE: --------------hEYLkUNamhL1wyiKWb9g0fXH Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi,

On 19.02.2025 18:41, Sergey Kaplun wrote:
Hi, Sergey!
Thanks for the fixes!

On 19.02.25, Sergey Bronnikov wrote:
Hi, Sergey,

thanks for review!

On 19.02.2025 11:06, Sergey Kaplun via Tarantool-patches wrote:
<snipped>

It's more LuaJIT-way to use something like the following:
| if (!LJ_HASSYSPROF) {
|   /* ... */
| }

This helps to avoid strange early return.
Fixed.
Also, please be avaired to declare all variables (stataus, opt,
err_details) in the beginning of the block.
  It is a requirement for the code that strictly follows c89, when you 
must declare all of your variables at the beginning of a scope block.

AFAIK, we have no such requirement, and also there is no option 
"-std=c89" in CI and no any mentions in the contribution guide.
This is not mentioned in Tarantool's contribution guide, since it is
LuaJIT-specific. In the perfect world, it should be checked by the flags
mentioned in <src/Makefile.original> (see the second CWARN).
Unfortunately, there are some bugs that should be fixed first.

<snipped>

Fixed:


diff --git a/src/lib_misc.c b/src/lib_misc.c
index aaf08718..7b934e52 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -312,15 +312,14 @@ static int sysprof_error(lua_State *L, int status, const char *err_details)
 LJLIB_CF(misc_sysprof_start)
 {
   const char *err_details = NULL;
+  int status = PROFILE_SUCCESS;
+  struct luam_Sysprof_Options opt = {};
+
   if (!LJ_HASSYSPROF) {
     err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
     return sysprof_error(L, PROFILE_ERRUSE, err_details);
   }
 
-  int status = PROFILE_SUCCESS;
-
-  struct luam_Sysprof_Options opt = {};
-
   status = parse_sysprof_opts(L, &opt, &err_details);
   if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
     return sysprof_error(L, status, err_details);
@@ -337,11 +336,11 @@ LJLIB_CF(misc_sysprof_start)
 /* local res, err, errno = profile.sysprof_stop() */
 LJLIB_CF(misc_sysprof_stop)
 {
+  int status = luaM_sysprof_stop(L);
   if (!LJ_HASSYSPROF) {
     const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
     return sysprof_error(L, PROFILE_ERRUSE, err_details);
   }
-  int status = luaM_sysprof_stop(L);
   if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
     return sysprof_error(L, status, NULL);
 
@@ -352,15 +351,15 @@ LJLIB_CF(misc_sysprof_stop)
 /* local counters, err, errno = sysprof.report() */
 LJLIB_CF(misc_sysprof_report)
 {
+  struct luam_Sysprof_Counters counters = {};
+  GCtab *data_tab = NULL;
+  GCtab *count_tab = NULL;
+  int status = luaM_sysprof_report(&counters);
   if (!LJ_HASSYSPROF) {
     const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
     return sysprof_error(L, PROFILE_ERRUSE, err_details);
   }
-  struct luam_Sysprof_Counters counters = {};
-  GCtab *data_tab = NULL;
-  GCtab *count_tab = NULL;
 
-  int status = luaM_sysprof_report(&counters);
   if (status != PROFILE_SUCCESS)
     return sysprof_error(L, status, NULL);
 
@@ -395,14 +394,14 @@ LJLIB_CF(misc_sysprof_report)
 /* local started, err, errno = misc.memprof.start(fname) */
 LJLIB_CF(misc_memprof_start)
 {
-  if (!LJ_HASMEMPROF) {
-    const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
-    return sysprof_error(L, PROFILE_ERRUSE, err_details);
-  }
   struct lj_memprof_options opt = {0};
   const char *fname = strdata(lj_lib_checkstr(L, 1));
   struct profile_ctx *ctx;
   int memprof_status;
+  if (!LJ_HASMEMPROF) {
+    const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
+    return sysprof_error(L, PROFILE_ERRUSE, err_details);
+  }
 
   /*
   ** FIXME: more elegant solution with ctx.
@@ -453,11 +452,11 @@ LJLIB_CF(misc_memprof_start)
 /* local stopped, err, errno = misc.memprof.stop() */
 LJLIB_CF(misc_memprof_stop)
 {
+  int status = lj_memprof_stop(L);
   if (!LJ_HASMEMPROF) {
     const char *err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);
     return sysprof_error(L, PROFILE_ERRUSE, err_details);
   }
-  int status = lj_memprof_stop(L);
   if (status != PROFILE_SUCCESS) {
     switch (status) {
     case PROFILE_ERRUSE:


    
--------------hEYLkUNamhL1wyiKWb9g0fXH--