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 BC58B1B693B0; Wed, 18 Mar 2026 13:47:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BC58B1B693B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1773830868; bh=qY4cW1B6ZIcSbOqn1a5M8xagfxwzUeaa45ILIwTl/MQ=; 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=xsotf8B/G0ZKPxX7Wz0EQO+yizcHGxVVXceK4ZQYYZm4gG6C0ABN6Xs3lvAJ3s8xH CM+ipBIpr73rOwlm8rxpAPyUgaSi114lSAS3NV4+pQzWtJjujJLK38CoZWl0H4crxB nhlUJKgZNQaCVBBAL8wcXnLyRwGY7cOF2yDL9xSs= Received: from send128.i.mail.ru (send128.i.mail.ru [89.221.237.223]) (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 A42A21B693BD for ; Wed, 18 Mar 2026 13:47:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A42A21B693BD Received: by exim-smtp-57656fb979-4wk5q with esmtpa (envelope-from ) id 1w2oRF-00000000AQn-0IV4; Wed, 18 Mar 2026 13:47:45 +0300 Content-Type: multipart/alternative; boundary="------------ozwuPYCI0GJXi5YSIW13dgrO" Message-ID: Date: Wed, 18 Mar 2026 13:47:44 +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: <7f14d93b-f295-434f-898c-3409daee3053@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9A2BFDE4DD2630CDAA3CAE0A9D55E2370BE52909E54144C6D182A05F5380850402F356E41D64E9D723DE06ABAFEAF67058503C7B1A09AE9F3A14FAE00CD2F926120238F7D6E9CF586 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76DD23B0452F84E3CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566BCD8AD057D84402CED7C1B9BECE432E78EA597B1B6CCA0FD6D26467A6E8006AB389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A3E989B1926288338941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE77DCDFB3399A2F72843847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A55DE1EB4C2CC5570E5002B1117B3ED6964E42D96D92D83556E41E333F9D1358D5823CB91A9FED034534781492E4B8EEADDFC043C56F70D752BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65932A95964D067CBB79DE7D7A04A63592F55BA16126F8F3F97F41C8AF744DC999527879B44A433C14DB8341EE9D5BE9A0A8A2CD7F34A040B01383DCF10490E915BA5BE24B63A1AFC896536EB022892E5344C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdbVVJCphTR/obs6jV0g8as= X-DA7885C5: 2093CC4220C94FF9F255D290C0D534F9EC287A31F415431E9686EE7CAB44086F7416F288B624AAC25B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE22DB4CA1E76677B0239E0AEF1C957479AF6466AB9E6011262EF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] misc: introduce flags with profiler support status 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. --------------ozwuPYCI0GJXi5YSIW13dgrO Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey, See my answers below. Sergey On 3/12/26 20:59, Sergey Kaplun wrote: > Hi, Sergey! > See my answers below. > > On 12.03.26, Sergey Bronnikov wrote: >> Hi, Sergey, >> >> thanks for review! See my comments. >> >> Sergey >> >> On 3/12/26 15:00, Sergey Kaplun via Tarantool-patches wrote: >>> Hi, Sergey! >>> Thanks for the patch! >>> Please consider my comments below. >>> >>> On 22.01.26, Sergey Bronnikov wrote: >>>> The patch introduce flags in module "misc" with support status >>>> for sysprof and memprof: `misc.sysprof.enabled` and >>>> `misc.memprof.enabled`. Both flags are boolean and always >>> Let's rename it to `available` instead. The `enabled` may be interpreted >>> as `is_running`, and confuse the user then. >> I propose using `is_available` instead. > The Lua API has 0 functions in the snake_case. Even `funcinfo`, > `traceexitstub` from lib_jit.c have this naming style. Lets be > consistent with it, especially, since `is_` prefix doesn't change the > semantics. ok, let's rename to "available". diff --git a/src/lib_misc.c b/src/lib_misc.c index 6b2278c1..3463445c 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -479,10 +479,10 @@ LUALIB_API int luaopen_misc(struct lua_State *L)  #if !LJ_TARGET_WINDOWS    LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);    lua_pushboolean(L, LJ_HASMEMPROF); -  lua_setfield(L, -2, "enabled"); +  lua_setfield(L, -2, "available");    LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);    lua_pushboolean(L, LJ_HASSYSPROF); -  lua_setfield(L, -2, "enabled"); +  lua_setfield(L, -2, "available");  #endif /* !LJ_TARGET_WINDOWS */    return 1;  } diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua index f867cfc6..2d2d43c1 100644 --- a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua +++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua @@ -19,7 +19,8 @@ test:ok(err:match('profiler is disabled'),          'error on stop when memprof is disabled') test:ok(type(errno) == 'number', 'errno on start when memprof is disabled') -test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists') -test:ok(misc.memprof.enabled == false, 'misc.memprof.enabled is false') +test:ok(type(misc.memprof.available) == 'boolean', +        'misc.memprof.available exists') +test:ok(misc.memprof.available == false, 'misc.memprof.available is false') test:done(true) diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua index 44ba8b08..a7aad80e 100644 --- a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua +++ b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua @@ -270,7 +270,8 @@ test:test("jit-output", function(subtest)    jit.opt.start(unpack(jit_opt_default))  end) -test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists') -test:ok(misc.memprof.enabled == true, 'misc.memprof.enabled is true') +test:ok(type(misc.memprof.available) == 'boolean', +        'misc.memprof.available exists') +test:ok(misc.memprof.available == true, 'misc.memprof.available is true') test:done(true) diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua index c023d8f1..5b9cc269 100644 --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua @@ -26,7 +26,8 @@ test:ok(err:match('profiler is disabled'),          'error on stop when sysprof is disabled') test:ok(type(errno) == 'number', 'errno on start when sysprof is disabled') -test:ok(type(misc.sysprof.enabled) == 'boolean', 'misc.sysprof.enabled exists') -test:ok(misc.sysprof.enabled == false, 'misc.sysprof.enabled is false') +test:ok(type(misc.sysprof.available) == 'boolean', +        'misc.sysprof.available exists') +test:ok(misc.sysprof.available == false, 'misc.sysprof.available is false') test:done(true) diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua index 41ed43e0..86115b62 100644 --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua @@ -228,7 +228,8 @@ check_mode("C", 100)  os.remove(TMP_BINFILE) -test:ok(type(misc.sysprof.enabled) == 'boolean', 'misc.sysprof.enabled exists') -test:ok(misc.sysprof.enabled == true, 'misc.sysprof.enabled is true') +test:ok(type(misc.sysprof.available) == 'boolean', +        'misc.sysprof.available exists') +test:ok(misc.sysprof.available == true, 'misc.sysprof.available is true') test:done(true) >>>> available on platforms supported by profilers (Windows is not >>>> supported). >>>> >>>> Closes tarantool/tarantool#12215 >>> Minor: Should be Resolves, since it is closed when we bump LuaJIT in the >>> Tarantool repository. >> Ok, updated. >>>> --- >>>> src/lib_misc.c | 4 ++++ >>>> .../profilers/misclib-memprof-lapi-disabled.test.lua | 5 ++++- >>>> test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua | 5 ++++- >>>> .../profilers/misclib-sysprof-lapi-disabled.test.lua | 5 ++++- >>>> test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua | 5 ++++- >>>> 5 files changed, 20 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/src/lib_misc.c b/src/lib_misc.c >>>> index 034ff878..6b2278c1 100644 >>>> --- a/src/lib_misc.c >>>> +++ b/src/lib_misc.c >>>> @@ -478,7 +478,11 @@ LUALIB_API int luaopen_misc(struct lua_State *L) >>>> LJ_LIB_REG(L, LUAM_MISCLIBNAME, misc); >>>> #if !LJ_TARGET_WINDOWS >>>> LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof); >>>> + lua_pushboolean(L, LJ_HASMEMPROF); >>>> + lua_setfield(L, -2, "enabled"); >>>> LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof); >>>> + lua_pushboolean(L, LJ_HASSYSPROF); >>>> + lua_setfield(L, -2, "enabled"); >>> Is it possible to use standard `LJLIB_PUSH() LJLIB_SET()` machinery >>> instead? >> I didn't get what is a macros `LJLIB_SET`. >> >> Also, what are the benefits with using mentioned macros instead more >> standard Lua API functions? > It is more consistent with the rest of the code base. > Also, it helps to avoid table rehasing on library initialization. > You may see details in buildvm_lib.c > Updated: diff --git a/src/lib_misc.c b/src/lib_misc.c index 3463445c..62886242 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -389,6 +389,8 @@ LJLIB_CF(misc_sysprof_report)  #endif /* !LJ_HASSYSPROF */  } +LJLIB_PUSH(top-2) LJLIB_SET(available) +  /* ----- misc.memprof module ---------------------------------------------- */  #define LJLIB_MODULE_misc_memprof @@ -459,6 +461,8 @@ LJLIB_CF(misc_memprof_stop)  }  #endif /* !LJ_TARGET_WINDOWS */ +LJLIB_PUSH(top-2) LJLIB_SET(available) +  #include "lj_libdef.h"  /* ------------------------------------------------------------------------ */ @@ -477,12 +481,10 @@ LUALIB_API int luaopen_misc(struct lua_State *L)    LJ_LIB_REG(L, LUAM_MISCLIBNAME, misc);  #if !LJ_TARGET_WINDOWS -  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);    lua_pushboolean(L, LJ_HASMEMPROF); -  lua_setfield(L, -2, "available"); -  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof); +  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);    lua_pushboolean(L, LJ_HASSYSPROF); -  lua_setfield(L, -2, "available"); +  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);  #endif /* !LJ_TARGET_WINDOWS */    return 1;  } >> >>>> #endif /* !LJ_TARGET_WINDOWS */ >>>> return 1; >>>> } >>>> diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua >>>> index de0aa136..f867cfc6 100644 >>>> --- a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua >>>> +++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua >>>> @@ -3,7 +3,7 @@ local test = tap.test('misclib-memprof-lapi-disabled'):skipcond({ >>>> ['Memprof is enabled'] = not os.getenv('LUAJIT_DISABLE_MEMPROF'), >>>> }) >>>> >>>> -test:plan(6) >>>> +test:plan(8) >>>> >>>> -- Attempt to start memprof when it is disabled. >>>> local res, err, errno = misc.memprof.start() >>>> @@ -19,4 +19,7 @@test:ok(err:match('profiler is disabled'), >>>> 'error on stop when memprof is disabled') >>>> test:ok(type(errno) == 'number', 'errno on start when memprof is disabled') >>>> >>>> +test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists') >>> I suppose that >>> |test:is(misc.memprof.available, false, 'misc.memprof.enabled correct') >>> is enough. >>> >>> Same for other tests below. >> if "misc.memprof" is not a table the error will be "attempt to index field" > Don't get the point here: > 1) We will see this error much earlier in that case. > 2) We will see with your approach as well. > > I don't get the reason for the `type()` call if the check below will > fail with a different type as well (since Lua checks types first). I see > no reason in double-checking that means nothing. The same sense as with checking both boolean value for pcall and an error message, see for example your patch in [1]: +test:ok(not result, 'correct status for recursive call') +test:like(errmsg, 'stack overflow', 'correct error message for recursive call') In aforementioned patch you can check only message, but you check both values. 1. https://lists.tarantool.org/tarantool-patches/20260316104853.23901-1-skaplun@tarantool.org/T/#u > > Also, `is()` check is more verbose in case of failure -- it prints got > and expected values. It's much easier for me to read that a type check failed than to figure out why the value is incorrect. The TAP checks produce completely unreadable message; I never use them. >>> >>>> +test:ok(misc.memprof.enabled == false, 'misc.memprof.enabled is false') >>>> + >>>> test:done(true) >>>> diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua >>>> index cd675864..44ba8b08 100644 >>>> --- a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua >>>> +++ b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua >>> >>> >>>> diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua >>>> index 2a9ce796..c023d8f1 100644 >>>> --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua >>>> +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua >>> >>> >>>> diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua >>>> index 701d58e4..41ed43e0 100644 >>>> --- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua >>>> +++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua >>> >>> >>>> -- >>>> 2.43.0 >>>> --------------ozwuPYCI0GJXi5YSIW13dgrO Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey,

See my answers below.

Sergey

On 3/12/26 20:59, Sergey Kaplun wrote:
Hi, Sergey!
See my answers below.

On 12.03.26, Sergey Bronnikov wrote:
Hi, Sergey,

thanks for review! See my comments.

Sergey

On 3/12/26 15:00, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the patch!
Please consider my comments below.

On 22.01.26, Sergey Bronnikov wrote:
The patch introduce flags in module "misc" with support status
for sysprof and memprof: `misc.sysprof.enabled` and
`misc.memprof.enabled`. Both flags are boolean and always
Let's rename it to `available` instead. The `enabled` may be interpreted
as `is_running`, and confuse the user then.
I propose using `is_available` instead.
The Lua API has 0 functions in the snake_case. Even `funcinfo`,
`traceexitstub` from lib_jit.c have this naming style. Lets be
consistent with it, especially, since `is_` prefix doesn't change the
semantics.

ok, let's rename to "available".

diff --git a/src/lib_misc.c b/src/lib_misc.c
index 6b2278c1..3463445c 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -479,10 +479,10 @@ LUALIB_API int luaopen_misc(struct lua_State *L)
 #if !LJ_TARGET_WINDOWS
   LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);
   lua_pushboolean(L, LJ_HASMEMPROF);
-  lua_setfield(L, -2, "enabled");
+  lua_setfield(L, -2, "available");
   LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);
   lua_pushboolean(L, LJ_HASSYSPROF);
-  lua_setfield(L, -2, "enabled");
+  lua_setfield(L, -2, "available");
 #endif /* !LJ_TARGET_WINDOWS */
   return 1;
 }
diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
index f867cfc6..2d2d43c1 100644
--- a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
+++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
@@ -19,7 +19,8 @@ test:ok(err:match('profiler is disabled'),
         'error on stop when memprof is disabled')
 test:ok(type(errno) == 'number', 'errno on start when memprof is disabled')
 
-test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists')
-test:ok(misc.memprof.enabled == false, 'misc.memprof.enabled is false')
+test:ok(type(misc.memprof.available) == 'boolean',
+        'misc.memprof.available exists')
+test:ok(misc.memprof.available == false, 'misc.memprof.available is false')
 
 test:done(true)
diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
index 44ba8b08..a7aad80e 100644
--- a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
@@ -270,7 +270,8 @@ test:test("jit-output", function(subtest)
   jit.opt.start(unpack(jit_opt_default))
 end)
 
-test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists')
-test:ok(misc.memprof.enabled == true, 'misc.memprof.enabled is true')
+test:ok(type(misc.memprof.available) == 'boolean',
+        'misc.memprof.available exists')
+test:ok(misc.memprof.available == true, 'misc.memprof.available is true')
 
 test:done(true)
diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
index c023d8f1..5b9cc269 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
@@ -26,7 +26,8 @@ test:ok(err:match('profiler is disabled'),
         'error on stop when sysprof is disabled')
 test:ok(type(errno) == 'number', 'errno on start when sysprof is disabled')
 
-test:ok(type(misc.sysprof.enabled) == 'boolean', 'misc.sysprof.enabled exists')
-test:ok(misc.sysprof.enabled == false, 'misc.sysprof.enabled is false')
+test:ok(type(misc.sysprof.available) == 'boolean',
+        'misc.sysprof.available exists')
+test:ok(misc.sysprof.available == false, 'misc.sysprof.available is false')
 
 test:done(true)
diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
index 41ed43e0..86115b62 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
@@ -228,7 +228,8 @@ check_mode("C", 100)
 
 os.remove(TMP_BINFILE)
 
-test:ok(type(misc.sysprof.enabled) == 'boolean', 'misc.sysprof.enabled exists')
-test:ok(misc.sysprof.enabled == true, 'misc.sysprof.enabled is true')
+test:ok(type(misc.sysprof.available) == 'boolean',
+        'misc.sysprof.available exists')
+test:ok(misc.sysprof.available == true, 'misc.sysprof.available is true')
 
 test:done(true)


      

          
available on platforms supported by profilers (Windows is not
supported).

Closes tarantool/tarantool#12215
Minor: Should be Resolves, since it is closed when we bump LuaJIT in the
Tarantool repository.
Ok, updated.

          
---
  src/lib_misc.c                                               | 4 ++++
  .../profilers/misclib-memprof-lapi-disabled.test.lua         | 5 ++++-
  test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua | 5 ++++-
  .../profilers/misclib-sysprof-lapi-disabled.test.lua         | 5 ++++-
  test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua | 5 ++++-
  5 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/lib_misc.c b/src/lib_misc.c
index 034ff878..6b2278c1 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -478,7 +478,11 @@ LUALIB_API int luaopen_misc(struct lua_State *L)
    LJ_LIB_REG(L, LUAM_MISCLIBNAME, misc);
  #if !LJ_TARGET_WINDOWS
    LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);
+  lua_pushboolean(L, LJ_HASMEMPROF);
+  lua_setfield(L, -2, "enabled");
    LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);
+  lua_pushboolean(L, LJ_HASSYSPROF);
+  lua_setfield(L, -2, "enabled");
Is it possible to use standard `LJLIB_PUSH() LJLIB_SET()` machinery
instead?
I didn't get what is a macros `LJLIB_SET`.

Also, what are the benefits with using mentioned macros instead more 
standard Lua API functions?
It is more consistent with the rest of the code base.
Also, it helps to avoid table rehasing on library initialization.
You may see details in buildvm_lib.c

Updated:

diff --git a/src/lib_misc.c b/src/lib_misc.c
index 3463445c..62886242 100644
--- a/src/lib_misc.c
+++ b/src/lib_misc.c
@@ -389,6 +389,8 @@ LJLIB_CF(misc_sysprof_report)
 #endif /* !LJ_HASSYSPROF */
 }
 
+LJLIB_PUSH(top-2) LJLIB_SET(available)
+
 /* ----- misc.memprof module ---------------------------------------------- */
 
 #define LJLIB_MODULE_misc_memprof
@@ -459,6 +461,8 @@ LJLIB_CF(misc_memprof_stop)
 }
 #endif /* !LJ_TARGET_WINDOWS */
 
+LJLIB_PUSH(top-2) LJLIB_SET(available)
+
 #include "lj_libdef.h"
 
 /* ------------------------------------------------------------------------ */
@@ -477,12 +481,10 @@ LUALIB_API int luaopen_misc(struct lua_State *L)
 
   LJ_LIB_REG(L, LUAM_MISCLIBNAME, misc);
 #if !LJ_TARGET_WINDOWS
-  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);
   lua_pushboolean(L, LJ_HASMEMPROF);
-  lua_setfield(L, -2, "available");
-  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);
+  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".memprof", misc_memprof);
   lua_pushboolean(L, LJ_HASSYSPROF);
-  lua_setfield(L, -2, "available");
+  LJ_LIB_REG(L, LUAM_MISCLIBNAME ".sysprof", misc_sysprof);
 #endif /* !LJ_TARGET_WINDOWS */
   return 1;
 }



          
  #endif /* !LJ_TARGET_WINDOWS */
    return 1;
  }
diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
index de0aa136..f867cfc6 100644
--- a/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
+++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-disabled.test.lua
@@ -3,7 +3,7 @@ local test = tap.test('misclib-memprof-lapi-disabled'):skipcond({
    ['Memprof is enabled'] = not os.getenv('LUAJIT_DISABLE_MEMPROF'),
  })
  
-test:plan(6)
+test:plan(8)
  
  -- Attempt to start memprof when it is disabled.
  local res, err, errno = misc.memprof.start()
@@ -19,4 +19,7 @@test:ok(err:match('profiler is disabled'),
          'error on stop when memprof is disabled')
  test:ok(type(errno) == 'number', 'errno on start when memprof is disabled')
  
+test:ok(type(misc.memprof.enabled) == 'boolean', 'misc.memprof.enabled exists')
I suppose that
|test:is(misc.memprof.available, false, 'misc.memprof.enabled correct')
is enough.

Same for other tests below.
if "misc.memprof" is not a table the error will be "attempt to index field"
Don't get the point here:
1) We will see this error much earlier in that case.
2) We will see with your approach as well.

I don't get the reason for the `type()` call if the check below will
fail with a different type as well (since Lua checks types first). I see
no reason in double-checking that means nothing.

The same sense as with checking both boolean value for pcall and an error message, see for example

your patch in [1]:

+test:ok(not result, 'correct status for recursive call')
+test:like(errmsg, 'stack overflow', 'correct error message for recursive call')

In aforementioned patch you can check only message, but you check both values.

1. https://lists.tarantool.org/tarantool-patches/20260316104853.23901-1-skaplun@tarantool.org/T/#u


    

Also, `is()` check is more verbose in case of failure -- it prints got
and expected values.

It's much easier for me to read that a type check failed than to figure out why the value is incorrect.

The TAP checks produce completely unreadable message; I never use them.


      

+test:ok(misc.memprof.enabled == false, 'misc.memprof.enabled is false')
+
  test:done(true)
diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
index cd675864..44ba8b08 100644
--- a/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-memprof-lapi.test.lua
<snipped>

diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
index 2a9ce796..c023d8f1 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi-disabled.test.lua
<snipped>

diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
index 701d58e4..41ed43e0 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


    
--------------ozwuPYCI0GJXi5YSIW13dgrO--