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 B4F586EFDA; Thu, 12 May 2022 13:11:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B4F586EFDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1652350316; bh=+BjNYfsAHW+XMPZnVU8HXpuXn+vQqfs4PfjN5SbVGfw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=uQEIBv252biza+Akx7Hrun1yUZS9DtPImJ6troAneSS99M7Q5O21rAB4P1T/IQidI aEK42OSgPmflyOXTJWXLVZ6YIH9njWzEcnlJPSrZTuHAQcGY2PjASDo3Re1so65DkW O8FsmAB3QiQCKdZBjDjgLnAppqtJWDbYrDkMY7ik= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A339C6EFDA for ; Thu, 12 May 2022 13:11:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A339C6EFDA Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1np5nV-0002B4-AN; Thu, 12 May 2022 13:11:53 +0300 To: Sergey Ostanevich , Igor Munkin Date: Thu, 12 May 2022 13:09:37 +0300 Message-Id: <20220512100937.24037-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9086B0A94CD1F151485D2F2A1F5183E09205181F4BBDC3AB0182A05F5380850404C228DA9ACA6FE27115DFF8A159EA3041C6D27A32EBD73BB76ABE0C9604598E5F70553BF23347748 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EA3E6C6690B39D9B8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F1651D42D52DB7E282BDBC54BAE47C21117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C5351985B4A98E2A443847C11F186F3C59DAA53EE0834AAEE X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CB1C541B78B7D83558BAED86F70129094ABD4BAC89AE6F6319C2B6934AE262D3EE7EAB7254005DCEDDD01B8980DE9A861F36E2E0160E5C55395B8A2A0B6518DF68C46860778A80D548DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EB7BD66E9101C10025DA29230BFD40A366DC8DB095F3ECAC3B263275D84D57060B37E65350D70A381D7E09C32AA3244C039DB08AC778877F7DE67162A6A27F6569B6CAE0477E908D927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojHKf298534tnZKBUFK/IGNg== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D689F1E1AEA3A396380F620F4F63D349B50FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] Flush and close output file after profiling run. 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" From: Mike Pall Thanks to Sergey Ostanevich. Using `jit.p` with a file argument does not flush result to the file on profile stop. This patch adds missing close for the file descriptor on profile stop. Sergey Kaplun: * added the description and the test for the problem --- LuaJIT PR: https://github.com/LuaJIT/LuaJIT/pull/726 Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-726-profile-flush-close-full-ci Tarantool PR: https://github.com/tarantool/tarantool/pull/7128 src/jit/p.lua | 1 + .../lj-726-profile-flush-close.test.lua | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/tarantool-tests/lj-726-profile-flush-close.test.lua diff --git a/src/jit/p.lua b/src/jit/p.lua index 7be10586..4569d69e 100644 --- a/src/jit/p.lua +++ b/src/jit/p.lua @@ -238,6 +238,7 @@ local function prof_finish() prof_count1 = nil prof_count2 = nil prof_ud = nil + if out ~= stdout then out:close() end end end diff --git a/test/tarantool-tests/lj-726-profile-flush-close.test.lua b/test/tarantool-tests/lj-726-profile-flush-close.test.lua new file mode 100644 index 00000000..290bd722 --- /dev/null +++ b/test/tarantool-tests/lj-726-profile-flush-close.test.lua @@ -0,0 +1,29 @@ +local tap = require('tap') + +local test = tap.test('lj-726-profile-flush-close') +test:plan(1) + +local TEST_FILE = 'lj-726-profile-flush-close.profile' + +local function payload() + local r = 0 + for i = 1, 1e8 do + r = r + i + end + return r +end + +local p = require('jit.p') +p.start("f", TEST_FILE) +payload() +p.stop() + +local f, err = io.open(TEST_FILE) +assert(f, err) + +-- Check that file is not empty. +test:ok(f:read(0), 'profile output was flushed and closed') + +assert(os.remove(TEST_FILE)) + +os.exit(test:check() and 0 or 1) -- 2.34.1