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 68B355D6F21; Mon, 4 Sep 2023 18:56:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 68B355D6F21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1693843003; bh=UHXiJRkB5jzUbgR+3UnsmzanKfo0NKaBx3UDEshYWP0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tI/r+QXNiL5tsmFWOVEPC8HJgGBTPHpwAyORRLXpcdEcdeI6I8BFnpE3gAUQHAc4i Gpd+C8vXnsyL8lbcCw6E+uA9YrLoNrnkHOQXA+HgNov05eNIubj+T45un/+kanO9L8 3QGnVmXI+8jbF5hgttbwgQA+Q+dos0V2cM2I3onw= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [95.163.41.96]) (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 A48805D6F1D for ; Mon, 4 Sep 2023 18:55:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A48805D6F1D Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1qdBv0-009M3J-1G; Mon, 04 Sep 2023 18:55:14 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 4 Sep 2023 18:50:26 +0300 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD96E142CFC92DB15CD342C4AF73C9E08B6B9ADEEA67E086309182A05F5380850404CA28A44AF5E1398F8FFFBE4310B0FC8923013E48AB8AD46A9B62CA3E74F485C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74D0D2DEF2EB846B0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371750936FC250F8708638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D810C4664FB1113A4A4AF7B87CA9816173117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1ED7F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE437C869540D2AB0F8F49F126DDB898E8D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE31E1736EDDE8D4790C0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637021B7B85925F8E35EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A55FB938E2FA3C909C139A782FEC73E38D0C883B46308A393FF87CCE6106E1FC07E67D4AC08A07B9B0D2AC72D04CD5349B9C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF30D9E7CB76AA39F3EFF23B6CACA678906A1A9FF4D7B5841992F0DD0FEDF982247E72D8710CBEBF0EEA61C66FA002EE277F17E6BDDB9F224007A05E4B9F44AFF9A74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojNmsqR+t6vc/xI8q+SPJqeg== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769BBC91BBC31AA440AF8FFFBE4310B0FC85AB84C5967107110DEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 3/3] test: fix fix-mips64-spare-side-exit-patching 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This test may be flaky due to a non-monotonic filling of the vector with traces. Hence, `misc.getmetrics().jit_trace_num` (which is the total number of traces) is not the last trace number, so there is no mcode for it. This patch fixes flakyness from two sides: * The `fillmcode()` function now starts a search from the given trace itself, so there is no possible inconsistency with the growing vector. * The finding of the last trace number in the aforementioned test is now more bulletproof: we scan all numbers from the metrics value to the maxtrace value. The last number with an existing mcode is chosen as the resulting last trace number. --- ...x-mips64-spare-side-exit-patching.test.lua | 22 ++++++++++++++++--- test/tarantool-tests/utils/jit/generators.lua | 5 ++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/tarantool-tests/fix-mips64-spare-side-exit-patching.test.lua b/test/tarantool-tests/fix-mips64-spare-side-exit-patching.test.lua index 62933df9..703d8e69 100644 --- a/test/tarantool-tests/fix-mips64-spare-side-exit-patching.test.lua +++ b/test/tarantool-tests/fix-mips64-spare-side-exit-patching.test.lua @@ -8,9 +8,26 @@ local test = tap.test('fix-mips64-spare-side-exit-patching'):skipcond({ local generators = require('utils').jit.generators local frontend = require('utils').frontend +local jutil = require('jit.util') + +-- Allow compilation of up to 2000 traces to avoid flushes. +local MAXTRACE = 2000; test:plan(1) +local function find_last_trace() + local candidate = misc.getmetrics().jit_trace_num + for traceno = candidate, MAXTRACE do + -- There is no need for heavy calls here. Just use the + -- simplest one to invoke `lj_checktrace()`. + if jutil.tracemc(traceno) then + candidate = traceno + end + end + assert(jutil.tracemc(candidate), 'tracenum candidate is invalid') + return candidate +end + -- Make compiler work hard. jit.opt.start( -- No optimizations at all to produce more mcode. @@ -18,8 +35,7 @@ jit.opt.start( -- Try to compile all compiled paths as early as JIT can. 'hotloop=1', 'hotexit=1', - -- Allow compilation of up to 2000 traces to avoid flushes. - 'maxtrace=2000', + ('maxtrace=%d'):format(MAXTRACE), -- Allow to compile 8Mb of mcode to be sure the issue occurs. 'maxmcode=8192', -- Use big mcode area for traces to avoid usage of different @@ -59,7 +75,7 @@ for i = 1, MAX_SPARE_SLOT + 1 do parent(i) parent(i) parent(i) - last_traceno = misc.getmetrics().jit_trace_num + last_traceno = find_last_trace() end test:ok(true, 'all traces executed correctly') diff --git a/test/tarantool-tests/utils/jit/generators.lua b/test/tarantool-tests/utils/jit/generators.lua index 0189cd2a..14e0e3c3 100644 --- a/test/tarantool-tests/utils/jit/generators.lua +++ b/test/tarantool-tests/utils/jit/generators.lua @@ -32,9 +32,7 @@ function M.fillmcode(trace_from, size) -- Marker to check that traces are not flushed. local maxtraceno = getlast_traceno() local FLUSH_ERR = 'Traces are flushed, check your maxtrace, maxmcode options' - - local _, last_addr = jutil.tracemc(maxtraceno) - last_addr = canonicalize_address(last_addr) + local last_addr = addr_from -- Addresses of traces may increase or decrease depending on OS, -- so use absolute diff. @@ -104,6 +102,7 @@ function M.fillmcode(trace_from, size) -- Calculate the address of the last trace start. maxtraceno = last_traceno + local _ _, last_addr = jutil.tracemc(last_traceno) if not last_addr then error(FLUSH_ERR) -- 2.42.0