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 07ECCCD3396; Thu, 6 Jun 2024 14:01:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 07ECCCD3396 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1717671701; bh=M0YeStVgp9U++leLf05UdhUbQxXyxTvLpu00fQoZB14=; 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=jbO0jcE048JgJcYUEfsbaxf0zHG5Z+GZS+fDYiairAxB+ymJKWJEA9jbAda/VG9+z BryEyB4vcD/dm0VdByHeyYW7Ae7N1Qjm/11xVBKPbi0vxeo/K51HWfVrRzqrtYGnI0 c/ZW8TGSbF1zdptxzxyg9SEI1F+srIHHcM+y+6Q4= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [95.163.41.91]) (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 7B0EFCD339A for ; Thu, 6 Jun 2024 14:01:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7B0EFCD339A Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1sFAsD-00000008nPf-47Xy; Thu, 06 Jun 2024 14:01:38 +0300 Content-Type: multipart/alternative; boundary="------------BJpOMzlz4ggYScdDpf5WoB1b" Message-ID: <42b64daf-a9f6-4267-9d22-4c8d7b88fdca@tarantool.org> Date: Thu, 6 Jun 2024 14:01:37 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <7c0a7be30070d085d6ddd3b56c4338686e1c2baa.1713773432.git.skaplun@tarantool.org> In-Reply-To: <7c0a7be30070d085d6ddd3b56c4338686e1c2baa.1713773432.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95EAEBA1571A63500BAB8C3FDB126E9E0BB62CA78447CF514182A05F5380850403D775E9C71DA5119C7A4B249DE6549FDE1FEA26F1EC4D56662BEE45D99412EB72C3955A1DF2D7297 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7850A3F981F25E362EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D7C7E03580C3DB018638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F62F3143FFB07849BEE054A3E811A7C103962AC2BF979F9CCC7F00164DA146DAFE8445B8C89999728AA50765F79006375FFD5C25497261569FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C37EF884183F8E4D67117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFAD8457029A4ECE08BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B6BD15B5E67D6DC3FB76E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C488FCA1C2775224B43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A509A7EF13FD0D51185002B1117B3ED69605680B3B8A7CAAA6715D9AB585B0EB04823CB91A9FED034534781492E4B8EEADAE4FDBF11360AC9BBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF6695592CE0BC1E404339FBA0A2921A96DA51115FD5778D04BED37766FA221BC68A36B291CE9B2EB00094467C1BF539CD650EDD4783B5009664052D8C6B261AFF97007CA68026E765F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj3qkQfioj9XTOgj+W/lRbww== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D61406A533C482EB86FF777D5298CF2054AA46A51BA6AA48C9C4D0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v1 3/5] test: allow `jit.parse` to return aborted traces 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. --------------BJpOMzlz4ggYScdDpf5WoB1b Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sergey, thanks for the patch! Please see my comments below. On 22.04.2024 11:49, Sergey Kaplun wrote: > Now information about the abort of the trace is saved in the > `abort_reason` field of the corresponding structure. The > `jit.parse.finish()` returns now the second table containing aborted > traces. Each table key is a trace number containing an array of > potentially traces with this number, which was aborted. > > Needed for tarantool/tarantool#9924 > --- > .../unit-jit-parse-abort.test.lua | 38 +++++++++++++++++++ > test/tarantool-tests/utils/jit/parse.lua | 22 ++++++++--- > 2 files changed, 55 insertions(+), 5 deletions(-) > create mode 100644 test/tarantool-tests/unit-jit-parse-abort.test.lua > > diff --git a/test/tarantool-tests/unit-jit-parse-abort.test.lua b/test/tarantool-tests/unit-jit-parse-abort.test.lua > new file mode 100644 > index 00000000..91af5a56 > --- /dev/null > +++ b/test/tarantool-tests/unit-jit-parse-abort.test.lua > @@ -0,0 +1,38 @@ > +local tap = require('tap') > +local test = tap.test('unit-jit-parse'):skipcond({ Usually a name passed to `tap.test` matches to test file name, but here it is not matched. > + ['Test requires JIT enabled'] = not jit.status(), > + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', > +}) > + > +local jparse = require('utils').jit.parse > + > +-- XXX: Avoid other traces compilation due to hotcount collisions > +-- for predictable results. > +jit.off() > +jit.flush() > + > +test:plan(1) > + > +jit.on() > +-- We only need the abort reason in the test. > +jparse.start('t') I would add a comment with explanation what does 't' flag mean. Feel free to ignore. > + > +-- XXX: A trace always has at least 3 IR constants: for `nil`, > +-- `false`, and `true`. Always fails to record with the set > +-- `maxirconst` limit. > +jit.opt.start('hotloop=1', 'maxirconst=1') > + > +for _ = 1, 3 do end > + > +local _, aborted_traces = jparse.finish() > + > +jit.off() > + > +assert(aborted_traces and aborted_traces[1], 'aborted trace is persisted') > + > +-- We tried to compile only one trace. > +local reason = aborted_traces[1][1].abort_reason > + > +test:like(reason, 'trace too long', 'abort reason is correct') > + > +test:done(true) > diff --git a/test/tarantool-tests/utils/jit/parse.lua b/test/tarantool-tests/utils/jit/parse.lua > index bcef5b35..0ce7f7c8 100644 > --- a/test/tarantool-tests/utils/jit/parse.lua > +++ b/test/tarantool-tests/utils/jit/parse.lua > @@ -22,6 +22,7 @@ local function trace_new(n) > parent = nil, > parent_exitno = nil, > is_stitched = false, > + abort_reason = nil, > start_loc = nil, > bc = {}, > ir = {}, > @@ -87,9 +88,17 @@ local header_handlers = { > ctx.parsing_trace = nil > ctx.parsing = nil > end, > - abort = function(ctx, trace_num) > + abort = function(ctx, trace_num, line) > local traces = ctx.traces > assert(ctx.parsing_trace == trace_num) > + > + local aborted_traces = ctx.aborted_traces > + if not aborted_traces[trace_num] then > + aborted_traces[trace_num] = {} > + end > + traces[trace_num].abort_reason = line:match('-- (.+)$') > + table.insert(aborted_traces[trace_num], traces[trace_num]) > + > ctx.parsing_trace = nil > ctx.parsing = nil > traces[trace_num] = nil > @@ -137,11 +146,14 @@ end > local JDUMP_FILE > > local function parse_jit_dump() > - local ctx = {traces = {}} > + local ctx = { > + aborted_traces = {}, > + traces = {}, > + } > for line in io.lines(JDUMP_FILE) do > parse_line(ctx, line) > end > - return ctx.traces > + return ctx.traces, ctx.aborted_traces > end > > -- Start `jit.dump()` utility with the given flags, saving the > @@ -167,10 +179,10 @@ M.finish = function() > -- Enable traces compilation for `jit.dump` back. > jit.on(jdump.on, true) > jit.on(jdump.off, true) > - local traces = parse_jit_dump() > + local traces, aborted_traces = parse_jit_dump() > os.remove(JDUMP_FILE) > JDUMP_FILE = nil > - return traces > + return traces, aborted_traces > end > > -- Turn off compilation for the module to avoid side effects. --------------BJpOMzlz4ggYScdDpf5WoB1b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Sergey,


thanks for the patch! Please see my comments below.

On 22.04.2024 11:49, Sergey Kaplun wrote:
Now information about the abort of the trace is saved in the
`abort_reason` field of the corresponding structure. The
`jit.parse.finish()` returns now the second table containing aborted
traces. Each table key is a trace number containing an array of
potentially traces with this number, which was aborted.

Needed for tarantool/tarantool#9924
---
 .../unit-jit-parse-abort.test.lua             | 38 +++++++++++++++++++
 test/tarantool-tests/utils/jit/parse.lua      | 22 ++++++++---
 2 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 test/tarantool-tests/unit-jit-parse-abort.test.lua

diff --git a/test/tarantool-tests/unit-jit-parse-abort.test.lua b/test/tarantool-tests/unit-jit-parse-abort.test.lua
new file mode 100644
index 00000000..91af5a56
--- /dev/null
+++ b/test/tarantool-tests/unit-jit-parse-abort.test.lua
@@ -0,0 +1,38 @@
+local tap = require('tap')
+local test = tap.test('unit-jit-parse'):skipcond({

Usually a name passed to `tap.test` matches to test file name,

but here it is not matched.

+  ['Test requires JIT enabled'] = not jit.status(),
+  ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
+})
+
+local jparse = require('utils').jit.parse
+
+-- XXX: Avoid other traces compilation due to hotcount collisions
+-- for predictable results.
+jit.off()
+jit.flush()
+
+test:plan(1)
+
+jit.on()
+-- We only need the abort reason in the test.
+jparse.start('t')

I would add a comment with explanation what does 't' flag mean.

Feel free to ignore.

+
+-- XXX: A trace always has at least 3 IR constants: for `nil`,
+-- `false`, and `true`. Always fails to record with the set
+-- `maxirconst` limit.
+jit.opt.start('hotloop=1', 'maxirconst=1')
+
+for _ = 1, 3 do end
+
+local _, aborted_traces = jparse.finish()
+
+jit.off()
+
+assert(aborted_traces and aborted_traces[1], 'aborted trace is persisted')
+
+-- We tried to compile only one trace.
+local reason = aborted_traces[1][1].abort_reason
+
+test:like(reason, 'trace too long', 'abort reason is correct')
+
+test:done(true)
diff --git a/test/tarantool-tests/utils/jit/parse.lua b/test/tarantool-tests/utils/jit/parse.lua
index bcef5b35..0ce7f7c8 100644
--- a/test/tarantool-tests/utils/jit/parse.lua
+++ b/test/tarantool-tests/utils/jit/parse.lua
@@ -22,6 +22,7 @@ local function trace_new(n)
     parent = nil,
     parent_exitno = nil,
     is_stitched = false,
+    abort_reason = nil,
     start_loc = nil,
     bc = {},
     ir = {},
@@ -87,9 +88,17 @@ local header_handlers = {
     ctx.parsing_trace = nil
     ctx.parsing = nil
   end,
-  abort = function(ctx, trace_num)
+  abort = function(ctx, trace_num, line)
     local traces = ctx.traces
     assert(ctx.parsing_trace == trace_num)
+
+    local aborted_traces = ctx.aborted_traces
+    if not aborted_traces[trace_num] then
+      aborted_traces[trace_num] = {}
+    end
+    traces[trace_num].abort_reason = line:match('-- (.+)$')
+    table.insert(aborted_traces[trace_num], traces[trace_num])
+
     ctx.parsing_trace = nil
     ctx.parsing = nil
     traces[trace_num] = nil
@@ -137,11 +146,14 @@ end
 local JDUMP_FILE
 
 local function parse_jit_dump()
-  local ctx = {traces = {}}
+  local ctx = {
+    aborted_traces = {},
+    traces = {},
+  }
   for line in io.lines(JDUMP_FILE) do
     parse_line(ctx, line)
   end
-  return ctx.traces
+  return ctx.traces, ctx.aborted_traces
 end
 
 -- Start `jit.dump()` utility with the given flags, saving the
@@ -167,10 +179,10 @@ M.finish = function()
   -- Enable traces compilation for `jit.dump` back.
   jit.on(jdump.on, true)
   jit.on(jdump.off, true)
-  local traces = parse_jit_dump()
+  local traces, aborted_traces = parse_jit_dump()
   os.remove(JDUMP_FILE)
   JDUMP_FILE = nil
-  return traces
+  return traces, aborted_traces
 end
 
 -- Turn off compilation for the module to avoid side effects.
--------------BJpOMzlz4ggYScdDpf5WoB1b--