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 07228131B08C; Wed, 5 Mar 2025 17:29:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 07228131B08C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1741184948; bh=bfqBgGr0zSDDdv7jtn9eseZaw6uiD1njDT/E1SIK6pw=; 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=sjQ4PcIncIZiFUvHkJDk2uzTEDrpF2lOWUuyBv+mpWIUYeK00c/MOQni4kCjwgUiK 0xNReMWdKGkcg43dchNQjJgTq/cjeJn9Z7ysUuyBtsPTrgOI0l1Yz42NR6LWctYO1S sjcjrV8/cVZ1Kt2m3QisokQhZX5BKzwEnmvWxNuQ= Received: from send149.i.mail.ru (send149.i.mail.ru [89.221.237.244]) (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 B2B11131B088 for ; Wed, 5 Mar 2025 17:29:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B2B11131B088 Received: by exim-smtp-8cb569c79-9tgbs with esmtpa (envelope-from ) id 1tppk9-00000000DAO-0iHr; Wed, 05 Mar 2025 17:29:05 +0300 Content-Type: multipart/alternative; boundary="------------H5GosVdU0Zt5eyV9oa01g1Gv" Message-ID: <7c01b6c6-36f0-45d4-acb8-d26577254796@tarantool.org> Date: Wed, 5 Mar 2025 17:29:04 +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: <6f39b239-083c-4508-a364-1ba02b3b5ed3@tarantool.org> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C8AED3E6A44DB6ABFDCD53BBF41048049C796A527F736CF3182A05F538085040D950C4A60962F7183DE06ABAFEAF6705184B56B720CE747CCDD0CD6A3005F4D6FE100A7AB8CE52E2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7495A032B936E882FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566AE3F01DD33DDBDC8A7444B130469B830D539A878C86824569B6A02AC76FE459B389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0D9442B0B5983000E8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E5E764EB5D94DBD4CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224958C1606C78F2434E76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B6A4E49BB0F3BA1413AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7352B32DCB92A8600C6C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5A12CA73A516CF2205002B1117B3ED6963E7908A8A2451F256E5F408120975D33823CB91A9FED034534781492E4B8EEADB1D70E2111C441FFBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34A1AF43396E40A36F62E956D479D60012459CA3E74FB502DC61A5F1B4C6E7C9DFF9EF5A156BF4A1911D7E09C32AA3244CFE1CC5598CDE64A577DD89D51EBB7742D26CBDBB51FA3304EA455F16B58544A2557BDE0DD54B3590A5AE236DF995FB59978A700BF655EAEEED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVQiWK+2I7Y2s2UDJ9dfywqU= X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D614074D5ECF20A8538C7AC8EDD30083ED68EBD5DB3CEB8916FA20152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 8/8][v3] memprof: set default path to profiling output file 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. --------------H5GosVdU0Zt5eyV9oa01g1Gv Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Sergey! Updated and force-pushed. Sergey On 05.03.2025 13:57, Sergey Kaplun wrote: > Hi, Sergey! > See my answer below. > > On 24.02.25, Sergey Bronnikov wrote: >> Hi, Sergey, >> >> thanks for review! > > >>>> --- >>>> + >>>> + local default_output_file = 'memprof.bin' >>>> + os.remove(default_output_file) >>>> + >>>> + local _, _ = misc.memprof.start() >>> Minor: Do we want to check that the profiler starts successfully? >>> I suppose we should, since this is the expected behaviour for this >>> feature. In case the profiler is not started (old behaviour) we would >>> get an error from the branch below: profiler not running. This isn't a >>> verbose definition of what goes wrong. >> I don't get why we should check that profiler is started in a test for >> default output file. > If the `memprof.start()` call will fail in the test (for any reason), > the next call of `memprof.stop()` will return `false, "profiler is not > running"`. So, when debugging the test, we have no clue about the reason > for the not-started profiler, which is not very convenient. The patch below handles error from memprof start and stop: diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua index ae8a73c9..55b5c60b 100644 --- a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua +++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua @@ -16,21 +16,26 @@ test:test('default-output-file', function(subtest)    local default_output_file = 'memprof.bin'    os.remove(default_output_file) -  local _, _ = misc.memprof.start() - -  local res, err = misc.memprof.stop() +  local res, err = misc.memprof.start() +  -- Want to cleanup carefully if something went wrong. +  if not res then + test:fail('sysprof was not started: ' .. err) +    os.remove(default_output_file) +  end +  res, err = misc.memprof.stop()    -- Want to cleanup carefully if something went wrong.    if not res then + test:fail('sysprof was not started: ' .. err)      os.remove(default_output_file) -    error(err)    end +    local profile_buf = tools.read_file(default_output_file) subtest:ok(profile_buf ~= nil and #profile_buf ~= 0,               'default output file is not empty') -  -- We don't need it any more. +  -- We don't need it anymore.    os.remove(default_output_file)  end) > >>> I suppose we may use `goto` here like the following: >>> >>> | local res, err = misc.memprof.start() >>> | -- Should start successfully. >>> | if not res then >>> | goto err_handling >>> | end >>> | >>> | res, err = misc.memprof.stop() >>> | >>> | ::err_handling:: >>> | -- Want to cleanup carefully if something went wrong. >>> | if not res then >>> >>>> + >>>> + local res, err = misc.memprof.stop() >>>> + >>>> + -- Want to cleanup carefully if something went wrong. >>>> + if not res then >>>> + os.remove(default_output_file) >>>> + error(err) >>>> + end > > --------------H5GosVdU0Zt5eyV9oa01g1Gv Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey!

Updated and force-pushed.

Sergey

On 05.03.2025 13:57, Sergey Kaplun wrote:
Hi, Sergey!
See my answer below.

On 24.02.25, Sergey Bronnikov wrote:
Hi, Sergey,

thanks for review!
<snipped>

---
+
+  local default_output_file = 'memprof.bin'
+  os.remove(default_output_file)
+
+  local _, _ = misc.memprof.start()
Minor: Do we want to check that the profiler starts successfully?
I suppose we should, since this is the expected behaviour for this
feature. In case the profiler is not started (old behaviour) we would
get an error from the branch below: profiler not running. This isn't a
verbose definition of what goes wrong.
I don't get why we should check that profiler is started in a test for 
default output file.
If the `memprof.start()` call will fail in the test (for any reason),
the next call of `memprof.stop()` will return `false, "profiler is not
running"`. So, when debugging the test, we have no clue about the reason
for the not-started profiler, which is not very convenient.

The patch below handles error from memprof start and stop:

diff --git a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua
index ae8a73c9..55b5c60b 100644
--- a/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua
+++ b/test/tarantool-tests/profilers/misclib-memprof-lapi-default-file.test.lua
@@ -16,21 +16,26 @@ test:test('default-output-file', function(subtest)
   local default_output_file = 'memprof.bin'
   os.remove(default_output_file)
 
-  local _, _ = misc.memprof.start()
-
-  local res, err = misc.memprof.stop()
+  local res, err = misc.memprof.start()
+  -- Want to cleanup carefully if something went wrong.
+  if not res then
+    test:fail('sysprof was not started: ' .. err)
+    os.remove(default_output_file)
+  end
 
+  res, err = misc.memprof.stop()
   -- Want to cleanup carefully if something went wrong.
   if not res then
+    test:fail('sysprof was not started: ' .. err)
     os.remove(default_output_file)
-    error(err)
   end
 
+
   local profile_buf = tools.read_file(default_output_file)
   subtest:ok(profile_buf ~= nil and #profile_buf ~= 0,
              'default output file is not empty')
 
-  -- We don't need it any more.
+  -- We don't need it anymore.
   os.remove(default_output_file)
 end)
 


I suppose we may use `goto` here like the following:

|   local res, err = misc.memprof.start()
|   -- Should start successfully.
|   if not res then
|     goto err_handling
|   end
|
|   res, err = misc.memprof.stop()
|
| ::err_handling::
|   -- Want to cleanup carefully if something went wrong.
|   if not res then

+
+  local res, err = misc.memprof.stop()
+
+  -- Want to cleanup carefully if something went wrong.
+  if not res then
+    os.remove(default_output_file)
+    error(err)
+  end
<snipped>

--------------H5GosVdU0Zt5eyV9oa01g1Gv--