Skip to content

Commit 36effbe

Browse files
authored
Merge pull request #37682 from vchuravy/vc/perf_jitevents
Enable Perf JITEvents by default
2 parents 5fbe9d1 + b2220ed commit 36effbe

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ endif
8282
USE_OPROFILE_JITEVENTS ?= 0
8383

8484
# Set to 1 to enable profiling with perf
85-
USE_PERF_JITEVENTS ?= 0
85+
USE_PERF_JITEVENTS ?= 1
8686

8787
# assume we don't have LIBSSP support in our compiler, will enable later if likely true
8888
HAVE_SSP := 0

doc/src/manual/environment-variables.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ event listener for just-in-time (JIT) profiling.
313313
(`USE_INTEL_JITEVENTS` set to `1` in the build configuration), or
314314
* [OProfile](http://oprofile.sourceforge.net/news/) (`USE_OPROFILE_JITEVENTS` set to `1`
315315
in the build configuration).
316+
* [Perf](https://perf.wiki.kernel.org) (`USE_PERF_JITEVENTS` set to `1`
317+
in the build configuration). This integration is enabled by default.
318+
319+
### `ENABLE_GDBLISTENER`
320+
321+
If set to anything besides `0` enables GDB registration of Julia code on release builds.
322+
On debug builds of Julia this is always enabled. Recommended to use with `-g 2`.
323+
316324

317325
### `JULIA_LLVM_ARGS`
318326

doc/src/manual/profile.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ Or similary with `perf` :
342342
343343
```
344344
$ ENABLE_JITPROFILING=1 perf record -o /tmp/perf.data --call-graph dwarf ./julia /test/fastmath.jl
345-
$ perf report --call-graph -G
345+
$ perf inject --jit --input /tmp/perf.data --output /tmp/perf-jit.data
346+
$ perf report --call-graph -G -i /tmp/perf-jit.data
346347
```
347348
348349
There are many more interesting things that you can measure about your program, to get a comprehensive list

src/codegen.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7728,10 +7728,9 @@ extern "C" void jl_init_llvm(void)
77287728
std::string DL = jl_data_layout.getStringRepresentation() + "-ni:10:11:12:13";
77297729
jl_data_layout.reset(DL);
77307730

7731-
// Register GDB event listener
7732-
#ifdef JL_DEBUG_BUILD
7733-
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
7734-
#endif
7731+
// Register GDB event listener
7732+
if(jl_using_gdb_jitevents)
7733+
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
77357734

77367735
#ifdef JL_USE_INTEL_JITEVENTS
77377736
if (jl_using_intel_jitevents)

src/init.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ char jl_using_oprofile_jitevents = 0; // Non-zero if running under OProfile
436436
char jl_using_perf_jitevents = 0;
437437
#endif
438438

439+
char jl_using_gdb_jitevents = 0;
440+
439441
int isabspath(const char *in) JL_NOTSAFEPOINT
440442
{
441443
#ifdef _OS_WINDOWS_
@@ -692,6 +694,15 @@ void _julia_init(JL_IMAGE_SEARCH rel)
692694
}
693695
#endif
694696

697+
#if defined(JL_DEBUG_BUILD)
698+
jl_using_gdb_jitevents = 1;
699+
# else
700+
const char *jit_gdb = getenv("ENABLE_GDBLISTENER");
701+
if (jit_gdb && atoi(jit_gdb)) {
702+
jl_using_gdb_jitevents = 1;
703+
}
704+
#endif
705+
695706
if ((jl_options.outputo || jl_options.outputbc || jl_options.outputasm) &&
696707
(jl_options.code_coverage || jl_options.malloc_log)) {
697708
jl_error("cannot generate code-coverage or track allocation information while generating a .o, .bc, or .s output file");

src/julia_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ extern char jl_using_oprofile_jitevents;
595595
#ifdef JL_USE_PERF_JITEVENTS
596596
extern char jl_using_perf_jitevents;
597597
#endif
598+
extern char jl_using_gdb_jitevents;
598599
extern size_t jl_arr_xtralloc_limit;
599600

600601
// -- init.c -- //

0 commit comments

Comments
 (0)