Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org,
	Sergey Kaplun <skaplun@tarantool.org>
Subject: [Tarantool-patches] [PATCH luajit] misc: introduce flags with profiler support status
Date: Thu, 22 Jan 2026 14:24:19 +0300	[thread overview]
Message-ID: <aee5ffc345f4e25ed20112224c659ac1744ec583.1769081050.git.sergeyb@tarantool.org> (raw)

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
available on platforms supported by profilers (Windows is not
supported).

Closes tarantool/tarantool#12215
---
 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");
 #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')
+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
@@ -11,7 +11,7 @@ local test = tap.test("misclib-memprof-lapi"):skipcond({
   ["Memprof is disabled"] = os.getenv("LUAJIT_DISABLE_MEMPROF"),
 })
 
-test:plan(5)
+test:plan(7)
 
 local jit_opt_default = {
     3, -- level
@@ -270,4 +270,7 @@ 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: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 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
@@ -3,7 +3,7 @@ local test = tap.test('misclib-sysprof-lapi-disabled'):skipcond({
   ['Sysprof is enabled'] = not os.getenv('LUAJIT_DISABLE_SYSPROF'),
 })
 
-test:plan(9)
+test:plan(11)
 
 -- Attempt to start sysprof when sysprof is disabled.
 local res, err, errno = misc.sysprof.start()
@@ -26,4 +26,7 @@ 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: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 701d58e4..41ed43e0 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
@@ -10,7 +10,7 @@ local test = tap.test("misclib-sysprof-lapi"):skipcond({
   ["Disabled due to #10803"] = os.getenv("LUAJIT_TEST_USE_VALGRIND"),
 })
 
-test:plan(45)
+test:plan(47)
 
 jit.off()
 -- XXX: Run JIT tuning functions in a safe frame to avoid errors
@@ -228,4 +228,7 @@ 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:done(true)
-- 
2.43.0


             reply	other threads:[~2026-01-22 11:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 11:24 Sergey Bronnikov via Tarantool-patches [this message]
2026-01-22 13:49 ` Sergey Bronnikov via Tarantool-patches

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=aee5ffc345f4e25ed20112224c659ac1744ec583.1769081050.git.sergeyb@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=estetus@gmail.com \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit] misc: introduce flags with profiler support status' \
    /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