Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Perf JITEvents by default #37682

Merged
merged 3 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endif
USE_OPROFILE_JITEVENTS ?= 0

# Set to 1 to enable profiling with perf
USE_PERF_JITEVENTS ?= 0
USE_PERF_JITEVENTS ?= 1
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have made this conditional on ifeq ($(OS),Linux), since LLVM now refuses to build on non-linux

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# assume we don't have LIBSSP support in our compiler, will enable later if likely true
HAVE_SSP := 0
Expand Down
8 changes: 8 additions & 0 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ event listener for just-in-time (JIT) profiling.
(`USE_INTEL_JITEVENTS` set to `1` in the build configuration), or
* [OProfile](http:https://oprofile.sourceforge.net/news/) (`USE_OPROFILE_JITEVENTS` set to `1`
in the build configuration).
* [Perf](https://perf.wiki.kernel.org) (`USE_PERF_JITEVENTS` set to `1`
in the build configuration). This integration is enabled by default.

### `ENABLE_GDBLISTENER`

If set to anything besides `0` enables GDB registration of Julia code on release builds.
On debug builds of Julia this is always enabled. Recommended to use with `-g 2`.


### `JULIA_LLVM_ARGS`

Expand Down
3 changes: 2 additions & 1 deletion doc/src/manual/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ Or similary with `perf` :

```
$ ENABLE_JITPROFILING=1 perf record -o /tmp/perf.data --call-graph dwarf ./julia /test/fastmath.jl
$ perf report --call-graph -G
$ perf inject --jit --input /tmp/perf.data --output /tmp/perf-jit.data
$ perf report --call-graph -G -i /tmp/perf-jit.data
```

There are many more interesting things that you can measure about your program, to get a comprehensive list
Expand Down
7 changes: 3 additions & 4 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7728,10 +7728,9 @@ extern "C" void jl_init_llvm(void)
std::string DL = jl_data_layout.getStringRepresentation() + "-ni:10:11:12:13";
jl_data_layout.reset(DL);

// Register GDB event listener
#ifdef JL_DEBUG_BUILD
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
#endif
// Register GDB event listener
if(jl_using_gdb_jitevents)
jl_ExecutionEngine->RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());

#ifdef JL_USE_INTEL_JITEVENTS
if (jl_using_intel_jitevents)
Expand Down
11 changes: 11 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ char jl_using_oprofile_jitevents = 0; // Non-zero if running under OProfile
char jl_using_perf_jitevents = 0;
#endif

char jl_using_gdb_jitevents = 0;

int isabspath(const char *in) JL_NOTSAFEPOINT
{
#ifdef _OS_WINDOWS_
Expand Down Expand Up @@ -692,6 +694,15 @@ void _julia_init(JL_IMAGE_SEARCH rel)
}
#endif

#if defined(JL_DEBUG_BUILD)
jl_using_gdb_jitevents = 1;
# else
const char *jit_gdb = getenv("ENABLE_GDBLISTENER");
if (jit_gdb && atoi(jit_gdb)) {
jl_using_gdb_jitevents = 1;
}
#endif

if ((jl_options.outputo || jl_options.outputbc || jl_options.outputasm) &&
(jl_options.code_coverage || jl_options.malloc_log)) {
jl_error("cannot generate code-coverage or track allocation information while generating a .o, .bc, or .s output file");
Expand Down
1 change: 1 addition & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ extern char jl_using_oprofile_jitevents;
#ifdef JL_USE_PERF_JITEVENTS
extern char jl_using_perf_jitevents;
#endif
extern char jl_using_gdb_jitevents;
extern size_t jl_arr_xtralloc_limit;

// -- init.c -- //
Expand Down