-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Reintegrate external profiling support #27466
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still prefer if we could use the OProfileWrapper
from LLVM instead of duplicating it here. Are there any patches we need for that?
@@ -0,0 +1 @@ | |||
788a11a35fa62eb008019b37187d09d2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rebase onto master which already should have these files (You should not check them int)
src/OProfileJITEventListener.cpp
Outdated
// Build a path from the current entry name | ||
SmallString<256> CmdLineFName; | ||
raw_svector_ostream(CmdLineFName) << "/proc/" << Entry->d_name | ||
<< "/cmdline"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting seems weird here
Well if we want to integrate line level annotations for OProfile yup, I need to patch the LLVM integration. Either way I agree, the OProfile code will be ditched as it is redundant, and I will register the event from LLVM, as is done with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! PerfJITEventListener.cpp
is from LLVM as well right? If so we should also add this as a patch and any changes that you made should be contributed back upstream.
deps/llvm.mk
Outdated
@@ -515,6 +515,8 @@ $(eval $(call LLVM_PATCH,llvm-D38765-gvn_5.0)) # Remove for 6.0 | |||
$(eval $(call LLVM_PATCH,llvm-D42262-jumpthreading-not-i1)) | |||
$(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC | |||
$(eval $(call LLVM_PATCH,llvm-PR36292-5.0)) # PPC fixes #26249, remove for 6.0 | |||
else ifeq ($(LLVM_VER_SHORT),6.0) | |||
$(eval $(call LLVM_PATCH,llvm-OProfile-line-num)) # In #27466, to be upstreamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably rebase your branch onto current master so that you have the other 6.0 patches as well
The PerfJITEventListener code has been moved to the LLVM patches, now the codebase seems much cleaner! I am still testing a bit with this, in particular you can follow the OProfile patch review at D47925. |
3041de2
to
2cd6ce4
Compare
Julia moved to LLVM 6.0, so no need to worry about 3.9.1 |
You probably also want to squash your commits into one introducing the LLVM patches and one or two for the integration work. |
d4b88ca
to
c8f7047
Compare
Yup it should be cleaner now As for a wrapper to Perf events in Julia LinuxPerf.jl will be maintained as an external package, so I took that out of th todo list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me (other than some minor formatting changes). Can you rebase to get CI to re-run? We'll also need BinaryBuilder to ingest these patches. But since this is off by default, I don't think that needs happen before merging.
src/jitlayers.cpp
Outdated
@@ -681,7 +682,16 @@ Function *JuliaOJIT::FindFunctionNamed(const std::string &Name) | |||
|
|||
void JuliaOJIT::RegisterJITEventListener(JITEventListener *L) | |||
{ | |||
// TODO | |||
if(!L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between if
and (
src/jitlayers.cpp
Outdated
void JuliaOJIT::NotifyFinalizer(const object::ObjectFile &Obj, | ||
const RuntimeDyld::LoadedObjectInfo &LoadedObjectInfo) | ||
{ | ||
for(auto &Listener : EventListeners) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between for
and (
src/codegen.cpp
Outdated
@@ -7474,6 +7474,22 @@ extern "C" void *jl_init_llvm(void) | |||
jl_setup_module(engine_module); | |||
jl_setup_module(m); | |||
return (void*)m; | |||
|
|||
#ifdef JL_USE_INTEL_JITEVENTS | |||
if(jl_using_intel_jitevents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between if
and (
c8f7047
to
7780444
Compare
(CI failures are unrelated – httpbin.com flakiness and macOS FileWatching) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash the commits and do we need to add https://reviews.llvm.org/D47343 and https://reviews.llvm.org/D44890?
deps/llvm.mk
Outdated
@@ -494,6 +498,9 @@ $(eval $(call LLVM_PATCH,llvm-rL332302)) # remove for 7.0 | |||
$(eval $(call LLVM_PATCH,llvm-rL332694)) # remove for 7.0 | |||
$(eval $(call LLVM_PATCH,llvm-rL327898)) # remove for 7.0 | |||
$(eval $(call LLVM_PATCH,llvm-6.0-DISABLE_ABI_CHECKS)) | |||
$(eval $(call LLVM_PATCH,llvm-OProfile-line-num)) # In #27466, to be upstreamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate
25821d8
to
781e001
Compare
|
Moved Oprofile Wrapper, implemented RegisterJITEventListener and NotifyFinalized Added PerfJITEventListener as an LLVM Patch Added IntelJITEventListener Support Added LLVM Patch, removed redundant Oprofile code, wipe blanklines, Register OProfile JITEvent, fixed oprofile compile flag, rebased llvm 6.0 checksums Added Perf profiling support as an LLVM patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, after CI passes
Julia external profiling plus perf support
As presented in #26999, during ORC JIT transition Julia lost the LLVM native support to register JIT events. This was my first activity.
Also with my mentors of the Gsoc we agreed on adding perf support, similarly to what @maleadt did in
#14727 .
Then I have added IntelJITEventListener and OProfile support. OProfile is currently missing line level code annotations, as the current OProfile LLVM support is not implementing it.
That's why I have linked directly the OPprofileJITEventListener code, to avoid having to re-compile LLVM each time 😅 .
This is an example of visualizing the Perf output of runtime code using gprof2dot.
TODO
PerfJITEventListener
class somewhere else, like indebuginfo.cpp
, as it is quite awful linked in the Makefile.@vtjnash suggested to add some features to the
@profile
macro. This can be useful, as perf support is intended to profile the whole runtime. I can add a feature so that a particular section of Julia code is profiled with perf events. Also it would not require to compile Julia with perf support.If anybody fthinks that this can be useful, I will work on that too.
EDIT: The perf wrapper is maintained as an external package.
cc @vtjnash @vchuravy