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 C188F514509; Fri, 7 Mar 2025 13:44:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C188F514509 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1741344263; bh=rKzfk8bUSDdCg3sdZR46TSYwyHyEuMZ0eKVPrF4YyOU=; 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=r7t9IQ7Tlaw9enBrURThGYXe7cKhNIFkZFalRIR2zZQ8BHqS3atrm/g0Rt4BuBR9y rX0XM9Zx9NJDXduPzUvBPQaLclSpXNmWFS4DmBaUDKCu+FKKeNNyLqIfQk1ppQTkHL V5OLPekZFXaxofya0giNZaGLdotzUi4tRR43CPRg= Received: from send34.i.mail.ru (send34.i.mail.ru [89.221.237.129]) (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 2B3FD514509 for ; Fri, 7 Mar 2025 13:44:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2B3FD514509 Received: by exim-smtp-8cb569c79-8ztrc with esmtpa (envelope-from ) id 1tqVBl-00000000R27-0sye; Fri, 07 Mar 2025 13:44:21 +0300 Content-Type: multipart/alternative; boundary="------------oyJgwP0Ti4b5KDRJQm3mkqR0" Message-ID: <9abf0268-66ed-43c4-8bf2-bb71534c3b7e@tarantool.org> Date: Fri, 7 Mar 2025 13:44:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun , Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org References: <99f54bbebab5e38184294664a944b3cc314cb140.1741277815.git.sergeyb@tarantool.org> Content-Language: en-US In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9D70A5F1A44F40AC4DEFAD4FC5E42960B3A3B94E6CA274DBF1313CFAB8367EF908E2BE116634AD74D408A4171B3BB33E803AAE3001806DF108FAA3FF2F7756D33927EEF339EB9AC3FE5719F5EA8C3A75A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7DB84ED444C624799EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375666B3C118DAE8E6700FEA17FCA24302460C0744D5DAC7E1E8943E4304105E25138389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6F459A8243F1D1D44CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224958C1606C78F2434E76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B6A4E49BB0F3BA1413AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735D028CC0B556B22BCC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5033C136F9AD239595002B1117B3ED696554E378F1511F5F414DB8790748E3E77823CB91A9FED034534781492E4B8EEAD21D4E6D365FE45D1BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF56BD388C7E090726C772B811E26E3A5FC7BE1B3F8AB90C1B01FE336D2D812088284AB208DE0D1BB1EDA8A7084F1AF318419F9B5E27DC24C2A82E5669BCDE10EF2A90B972F1A66D0C5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVQiWK+2I7Y2s1rvjx7oGF7w= X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140408A4171B3BB33E803AAE3001806DF105272A7EC4CBFDF8A0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 3/3] sysprof: fix a message with stop without run 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. --------------oyJgwP0Ti4b5KDRJQm3mkqR0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey! both issues were fixed and force-pushed to the branch. Sergey On 07.03.2025 10:21, Sergey Kaplun via Tarantool-patches wrote: > Hi, Sergey! > Thanks for the fixes! > LGTM, with 2 minor comments below. > > On 06.03.25, Sergey Bronnikov wrote: >> When sysprof is not started the function `misc.sysprof.stop()` > Typo: s/started/started,/ Fixed. > >> reports that the profiler is already running: >> >> | $ ./src/luajit -e 'print(misc.sysprof.stop())' >> | nil profiler is running already 22 >> >> The patch fixes that: >> >> | $ ./src/luajit -e 'print(misc.sysprof.stop())' >> | nil profiler is not running 22 >> >> Follows up tarantool/tarantool#781 >> --- > > >> + if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) { >> + lua_pushnil(L); >> + lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING)); >> + lua_pushinteger(L, EINVAL); >> + return 3; >> + } >> if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) > It looks like more natural now to use `else if` here now. Fixed, updated version: --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -336,8 +336,14 @@ LJLIB_CF(misc_sysprof_stop)    return prof_error(L, PROFILE_ERRUSE, err_details);  #else    int status = luaM_sysprof_stop(L); -  if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) +  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) { +    lua_pushnil(L); +    lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING)); +    lua_pushinteger(L, EINVAL); +    return 3; +  } else if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) {      return prof_error(L, status, NULL); +  }    lua_pushboolean(L, 1);    return 1; > >> return prof_error(L, status, NULL); >> >> diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua >> index 91ea461b..f316c390 100644 >> --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua >> +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua > > >> -- >> 2.43.0 >> --------------oyJgwP0Ti4b5KDRJQm3mkqR0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey!

both issues were fixed and force-pushed to the branch.

Sergey

On 07.03.2025 10:21, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the fixes!
LGTM, with 2 minor comments below.

On 06.03.25, Sergey Bronnikov wrote:
When sysprof is not started the function `misc.sysprof.stop()`
Typo: s/started/started,/
Fixed.

reports that the profiler is already running:

| $ ./src/luajit -e 'print(misc.sysprof.stop())'
| nil     profiler is running already     22

The patch fixes that:

| $ ./src/luajit -e 'print(misc.sysprof.stop())'
| nil     profiler is not running         22

Follows up tarantool/tarantool#781
---
<snipped>

+  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) {
+      lua_pushnil(L);
+      lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));
+      lua_pushinteger(L, EINVAL);
+      return 3;
+  }
   if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
It looks like more natural now to use `else if` here now.

Fixed, updated version:

--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -336,8 +336,14 @@ LJLIB_CF(misc_sysprof_stop)
   return prof_error(L, PROFILE_ERRUSE, err_details);
 #else
   int status = luaM_sysprof_stop(L);
-  if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
+  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) {
+    lua_pushnil(L);
+    lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));
+    lua_pushinteger(L, EINVAL);
+    return 3;
+  } else if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) {
     return prof_error(L, status, NULL);
+  }
 
   lua_pushboolean(L, 1);
   return 1;


     return prof_error(L, status, NULL);
 
diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
index 91ea461b..f316c390 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
<snipped>

-- 
2.43.0


    
--------------oyJgwP0Ti4b5KDRJQm3mkqR0--