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 5355A13DBE41; Wed, 4 Jun 2025 11:46:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5355A13DBE41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1749026818; bh=DcRk2Esi8GZdYPJNJrwCi/NC6CcXejFw95S3t/7YXVo=; 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=fBtnOCzs+bzeA8K3L4h3znkwgDH1nCa6Bwl3guHhOLybXdfJViY9W0MTtamB5mFmG jJ8S6oShB0EY9OHb/6/plSiyA5It6JOk3upYeAPPgUWJJ7EeJiHJ75ab3vb0qJmkJ/ s5wCPj2A3Jo+7jtLsd8eRuGdmnTCQy5pR2v6vvuo= Received: from send172.i.mail.ru (send172.i.mail.ru [95.163.59.11]) (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 A3B5013DBE42 for ; Wed, 4 Jun 2025 11:46:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A3B5013DBE42 Received: by exim-smtp-75656d46d5-d6lrt with esmtpa (envelope-from ) id 1uMjlv-000000007X3-2mxg; Wed, 04 Jun 2025 11:46:56 +0300 Content-Type: multipart/alternative; boundary="------------AduFnZRHkhgBP0qUZ8vdI7zt" Message-ID: <59b25b0e-7cfc-4e67-8716-403b2ca2713a@tarantool.org> Date: Wed, 4 Jun 2025 11:46:55 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <20250603173559.24591-1-skaplun@tarantool.org> Content-Language: en-US In-Reply-To: <20250603173559.24591-1-skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9851146C857904EABD06CD3671CA88EF6A38B264BDE327F2B182A05F538085040988837443B84BE443DE06ABAFEAF670530A1354222134C5464D29123B1398864A24CDA786A8AA87E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7624C4D757C4F5837EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FE9EFE935CD7C6AE8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B27F92BA12233DDDD22E070BE324C7D3C4DAACF4483ACE22F1F6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249E5E764EB5D94DBD4CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C04CF195F1528592878941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD269176DF2183F8FC7C0BCF2C0F5768D5B7A7B076A6E789B0E97A8DF7F3B2552694AD5FFEEA1DED7F25D49FD398EE364050F9647ADFADE5905B103CEA74F0D118906B3661434B16C20ACC84D3B47A649675FE827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F7900637F09814068C508CC822CA9DD8327EE4930A3850AC1BE2E735C8D5298E42E60C1FC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A545FA69C6FD77D01C5002B1117B3ED6961EBC07C9B39C0BEB466072E6821086B3823CB91A9FED034534781492E4B8EEADF1165EFABA1780A6BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADBF74143AD284FC7177DD89D51EBB7742424CF958EAFF5D571004E42C50DC4CA955A7F0CF078B5EC49A30900B95165D34431D0341F6B74DD34AA4DBC2BE808A68D62D21500C043FF9F0720D986B262FB1595887715B39FC4D1D7E09C32AA3244C8C8E7DC14455BE8277DD89D51EBB774245D0797571DC14F6EA455F16B58544A2E30DDF7C44BCB90DA5AE236DF995FB59978A700BF655EAEEED6A17656DB59BCAD427812AF56FC65B X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVSykAyseJQ6/gV4pv5GBOrA= X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140B8084A9A6A531C1991417EB218679B8278EE5FB56198CDA50152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] build: provide LUAJIT_USE_PERFTOOLS option 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. --------------AduFnZRHkhgBP0qUZ8vdI7zt Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! On 6/3/25 20:35, Sergey Kaplun wrote: > This patch provides the LUAJIT_USE_PERFTOOLS flag via the CMake build > system. It allows you to avoid the definition of the cognominal macro it's better to write impersonally: It allows avoiding the definition of ... Feel free to ignore. > definition via CMAKE_C_FLAGS to use integration with the Linux perf > tools interface [1] to resolve symbols for traces generated by a JIT. > > It may be used like the following: > > | perf record script -f luajit test.lua seems command is incorrect, because it does not work for me: script: unexpected number of arguments Try 'script --help' for more information. I've used instead: $ sudo perf record -F 2000 ./build/src/luajit fib.lua [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.024 MB perf.data (8 samples) ] > | perf report -s symbol > and "perf report /tmp/perf-1699839.map" to check that luajit report symbols in map file. > [1]:https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt > > Resolves tarantool/tarantool#11300 > --- > > Branch:https://github.com/tarantool/luajit/tree/skaplun/gh-11300-use-perftools-flag > Issue:https://github.com/tarantool/tarantool/issues/11300 > > CMakeLists.txt | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/CMakeLists.txt b/CMakeLists.txt > index 854b3613..c0da4362 100644 > --- a/CMakeLists.txt > +++ b/CMakeLists.txt > @@ -259,6 +259,14 @@ if(LUAJIT_USE_VALGRIND) > AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_VALGRIND) > endif() > > +# This creates a symbol table of the JIT-compiled code in > +# a (%d = pid of process) file. It should be > +# used with Linux perf tools. See for details. > +option(LUAJIT_USE_PERFTOOLS "Linux perf JIT support" OFF) > +if(LUAJIT_USE_PERFTOOLS) > + AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_PERFTOOLS) > +endif() Adding a CMake flag means that we support it in our fork (users will rely on this functionality). Do want a regression test for this option? > + > # This is the client for the GDB JIT API. GDB 7.0 or higher is > # required to make use of it. See lj_gdbjit.c for details. > # Enabling this causes a non-negligible overhead, even when not --------------AduFnZRHkhgBP0qUZ8vdI7zt Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for the patch!

On 6/3/25 20:35, Sergey Kaplun wrote:
This patch provides the LUAJIT_USE_PERFTOOLS flag via the CMake build
system. It allows you to avoid the definition of the cognominal macro

it's better to write impersonally: It allows avoiding the definition of ...

Feel free to ignore.


definition via CMAKE_C_FLAGS to use integration with the Linux perf
tools interface [1] to resolve symbols for traces generated by a JIT.

It may be used like the following:

| perf record script -f luajit test.lua

seems command is incorrect, because it does not work for me:

<snipped>

script: unexpected number of arguments
Try 'script --help' for more information.
<snipped>

I've used instead:

$ sudo perf record -F 2000 ./build/src/luajit fib.lua
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.024 MB perf.data (8 samples) ]

| perf report -s symbol

and "perf report /tmp/perf-1699839.map" to check that luajit report symbols in map file.
[1]: https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt

Resolves tarantool/tarantool#11300
---

Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-11300-use-perftools-flag
Issue: https://github.com/tarantool/tarantool/issues/11300

 CMakeLists.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 854b3613..c0da4362 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,6 +259,14 @@ if(LUAJIT_USE_VALGRIND)
   AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_VALGRIND)
 endif()
 
+# This creates a symbol table of the JIT-compiled code in
+# a </tmp/perf-%d.map> (%d = pid of process) file. It should be
+# used with Linux perf tools. See <src/lj_trace.c> for details.
+option(LUAJIT_USE_PERFTOOLS "Linux perf JIT support" OFF)
+if(LUAJIT_USE_PERFTOOLS)
+  AppendFlags(TARGET_C_FLAGS -DLUAJIT_USE_PERFTOOLS)
+endif()

Adding a CMake flag means that we support it in our fork (users will rely on this functionality).

Do want a regression test for this option?

+
 # This is the client for the GDB JIT API. GDB 7.0 or higher is
 # required to make use of it. See lj_gdbjit.c for details.
 # Enabling this causes a non-negligible overhead, even when not
--------------AduFnZRHkhgBP0qUZ8vdI7zt--