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 F195A1392626; Fri, 16 May 2025 15:38:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F195A1392626 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1747399140; bh=1nLvHPLJeO9AwXKOMPjjxYUonJenUZ2Nu+KEbek5CCk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=A1WT0FnD8KLrazJmFPMVJa5koF0+U5qyeGojW7gVDUCrxuOCHgQupn3483rkKlYD/ q1jlHWCnZW7/pCZTofzjJ21akGIi3WHplo09cTIFWtKhMiOm/7UIrI1083DLwwpzM9 z9TL6M+sCQwRqBDYACbmP3UbRXhNotaOgB24ZeCE= Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 0CD246ECDE for ; Fri, 16 May 2025 15:38:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0CD246ECDE Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-70c7b8794faso19770117b3.1 for ; Fri, 16 May 2025 05:38:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747399137; x=1748003937; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=icOFGZ7ZWYTskKgiq8j305+mc1TG9oc6ypFubPU3rsM=; b=rVX6aeAGMe+eiaHsu3Wg+YIJSRAu38rH5FWBgJrMwLeuHM/l58RiuN2KCCT1WONmkP buS3lHv+QHGXTktXR0u4o1Z5LNmvZs/gDEeSOkMDKxYKscEvt1sqhDLnUbx7W95sAt+f AXzoX+9gOPc7ufADOfdsLH3hblQgZ6JD0Gi1hAIs+7R5+pCvc9PNaJM+Jq9udgpVaYOC pRCL6lZ/heJa4tKqxvMphsTuhAz0PLqpRm/FaQ+3Q8VCP16y+0+yFIkNQ6FMtHZBoEtx 1fYPzoIZeLEE0iPkCPZCAXVlIvl8ZMWdv/tBbRXItcfWOh9BX2XcN8heSS5my4sS1yd/ ffJQ== X-Gm-Message-State: AOJu0Yx5ufJmIFRYbl3uvmddgR+GIZeJJZVH4cSA5F9nA33bunt7XdfW Ako/ZJfQQYMA3yaOcxUTpZMdgIFl6aNm6sbm3PjTzWrAjHOCQ4ViGVeTEtM4v3jIGiU= X-Gm-Gg: ASbGncu9smCAV8ryfw/WQvGMNnODUZCG5SQcGXLQBmZkbeNljdXRHgnarF0o2ba9Xoy 6nGDGxkcuKkvRqxjq5NqfjraID7ftu9UNXlsKdP2HCFjTs1wvpj9hp4gY24eQ6ZZewFmqjrwR+M 8N3vCU6xxTd3PBbdLyCwqF1snUfIksn7Z0EclNnttpwEWfpOb+ixd3MAcadr6EshAZz5cVG5jv5 i/FimpDcjf9NEk9KxBlXPUKaCoKURKowVyphdLxql8nX3TBDHProiLVlLf7LfI9utvQzGTH39jz pqpyJkXSJtLfG9ztDfZJ720zlMr+rFnFuCjDc0e6gw== X-Google-Smtp-Source: AGHT+IH3jsCftjMjM7kaNaboGFwyYeeCDT0OBUeM9ymnaeDdpyAmczv1X9xHzDvkE/AxprPb78Zw8Q== X-Received: by 2002:a05:690c:368c:b0:708:43f1:10a with SMTP id 00721157ae682-70ca79bfcc8mr53892427b3.10.1747399136654; Fri, 16 May 2025 05:38:56 -0700 (PDT) Received: from localhost ([5.181.62.98]) by smtp.gmail.com with ESMTPSA id 00721157ae682-70ca82ef9c9sm3841417b3.1.2025.05.16.05.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 May 2025 05:38:56 -0700 (PDT) X-Google-Original-From: Sergey Bronnikov To: tarantool-patches@dev.tarantool.org, Sergey Kaplun Date: Fri, 16 May 2025 15:38:43 +0300 Message-ID: <6aefeed4eee55e77e7c79ac9b31c284b014d2c7a.1747399055.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit][v1] sysprof: allow calling sysprof.report before stopping 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" 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