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][v1] sysprof: allow calling sysprof.report before stopping Date: Fri, 16 May 2025 15:38:43 +0300 [thread overview] Message-ID: <6aefeed4eee55e77e7c79ac9b31c284b014d2c7a.1747399055.git.sergeyb@tarantool.org> (raw) It is not allowed to call a function `sysprof.report()` without stopping profiler. However, sometimes it may be useful to analyze numbers provided by the report without stopping the profiler. The patch removes the appropriate condition and allows reporting without stopping. Resolves tarantool/tarantool#11229 --- Branch: https://github.com/tarantool/luajit/tree/ligurio/gh-11229-misc.sysprof.report Issue: https://github.com/tarantool/tarantool/issues/11229 src/lj_sysprof.c | 2 -- .../profilers/misclib-sysprof-lapi.test.lua | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lj_sysprof.c b/src/lj_sysprof.c index 88c7a41b..cf6161a5 100644 --- a/src/lj_sysprof.c +++ b/src/lj_sysprof.c @@ -532,8 +532,6 @@ int lj_sysprof_stop(lua_State *L) int lj_sysprof_report(struct luam_Sysprof_Counters *counters) { const struct sysprof *sp = &sysprof; - if (sp->state != SPS_IDLE) - return PROFILE_ERRUSE; memcpy(counters, &sp->counters, sizeof(sp->counters)); return PROFILE_SUCCESS; } diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua index f316c390..3e774a53 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(44) +test:plan(48) jit.off() -- XXX: Run JIT tuning functions in a safe frame to avoid errors @@ -166,13 +166,27 @@ test:is(err, nil, "no error with good interval 1") test:is(errno, nil, "no errno with good interval 1") misc.sysprof.stop() +-- Intermediate sysprof.report(). +res, err, errno = misc.sysprof.start{ + mode = "C", + interval = 1, + path = "/dev/null", +} +test:is(res, true, "res is correct") +test:is(err, nil, "no error") +test:is(errno, nil, "no errno") + +local report = misc.sysprof.report() +test:ok(report.samples == 0, "total number of samples is non-zero") +misc.sysprof.stop() + -- DEFAULT MODE if not pcall(generate_output, { mode = "D", interval = 100 }) then test:fail('`default` mode with interval 100') end -local report = misc.sysprof.report() +report = misc.sysprof.report() -- Check the profile is not empty. test:ok(report.samples > 0, -- 2.43.0
next reply other threads:[~2025-05-16 12:38 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-05-16 12:38 Sergey Bronnikov via Tarantool-patches [this message] 2025-06-04 8:35 ` Sergey Kaplun via Tarantool-patches 2025-06-04 11:07 ` Sergey Bronnikov via Tarantool-patches 2025-06-04 13:13 ` Sergey Kaplun via Tarantool-patches 2025-06-04 13:31 ` Sergey Bronnikov via Tarantool-patches 2025-06-04 8:36 ` Sergey Kaplun via Tarantool-patches 2025-06-04 11:19 ` 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=6aefeed4eee55e77e7c79ac9b31c284b014d2c7a.1747399055.git.sergeyb@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=estetus@gmail.com \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit][v1] sysprof: allow calling sysprof.report before stopping' \ /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