-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[MONO] Add JIT_CODE_DEBUG_INFO record functionality for Jitdump #85107
Conversation
@@ -2128,7 +2145,75 @@ mono_emit_jit_dump (MonoJitInfo *jinfo, gpointer code) | |||
|
|||
record.code_index = ++code_index; | |||
|
|||
// TODO: write debugInfo and unwindInfo immediately before the JitCodeLoadRecord (while lock is held). | |||
DebugEntry ent; |
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.
This should follow the mono coding conventions, see the rest of the file for examples.
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.
done. let me know if there is anything else
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.
changed the style to adhere to the mono coding conventions
@@ -2128,7 +2145,75 @@ mono_emit_jit_dump (MonoJitInfo *jinfo, gpointer code) | |||
|
|||
record.code_index = ++code_index; | |||
|
|||
// TODO: write debugInfo and unwindInfo immediately before the JitCodeLoadRecord (while lock is held). | |||
DebugEntry ent; |
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.
done. let me know if there is anything else
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 go through your change and fix the coding style. I've pointed out a few examples for you.
src/mono/mono/mini/mini-runtime.c
Outdated
guint32 line; | ||
guint32 discrim; | ||
char name[]; | ||
}DebugEntry; |
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.
}DebugEntry; | |
} DebugEntry; |
src/mono/mono/mini/mini-runtime.c
Outdated
guint64 code_addr; | ||
guint64 nr_entry; | ||
DebugEntry debug_entry[]; | ||
}JitCodeDebug; |
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.
}JitCodeDebug; | |
} JitCodeDebug; |
src/mono/mono/mini/mini-runtime.c
Outdated
|
||
static void add_basic_JitCodeDebug_info(JitCodeDebug *record); |
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.
static void add_basic_JitCodeDebug_info(JitCodeDebug *record); | |
static void add_basic_JitCodeDebug_info (JitCodeDebug *record); |
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.
In mono code base, we add a space between the function name and the "(". Please follow this function call style for all the code change in this PR.
src/mono/mono/mini/mini-runtime.c
Outdated
rec.code_addr = (guint64)dmji->code_start; | ||
rec.header.total_size = sizeof(rec) + sizeof(ent) + 1; | ||
rec.nr_entry=1; | ||
for(i=0;i < dmji->num_line_numbers;++i){ |
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.
Fix code style
src/mono/mono/mini/mini-runtime.c
Outdated
|
||
loc = mono_debug_lookup_source_location_by_il(jinfo->d.method,dmji->line_numbers[i].il_offset,NULL); | ||
|
||
if(!(loc) |
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.
if(!(loc) | |
if(!loc) |
Thank you for helping me out with the code style. I have made the changes accordingly. |
@fanyang-mono is there any other changes required to be made? |
@vargaz @lambdageek can someone see if this is ready to merge now? |
@fanyang-mono
It's creating multiple sets of .map and .dump files in the /tmp/ folder for one particular workload. Error: Perf tool is able to read .map files to do symbol resolution and show the data. And due to this, we are able to see the functions in the profile but not the annotations inside that which requires a .dump file. |
@shivanirmishra The runtime should generate the .dump file. can you cross check that under the I faced a similar issue and fixed the same : #82520 |
Hi @saitama951, yes runtime is generating the .dump file in the/tmp/ folder. |
@shivanirmishra the fix should be there in .NET 8 preview 4 or you can cherry pick the commit. |
@saitama951 |
@shivanirmishra I have fixed the |
Hi @saitama951, thank you for your help. |
/backport to release/7.0-staging |
Started backporting to release/7.0-staging: https://github.com/dotnet/runtime/actions/runs/5248244227 |
@saitama951 @fanyang-mono |
@shivanirmishra It seems source code annotation fails on top of the BenchmarkDotnet library. it works for sample programs without the BDN. I have been manually looking into the jitted-so's, everything looks good there as well. |
Thanks @saitama951 For Example: after running the |
Yes, I am working on backporting the fixes to regressions to 7.0 now. |
@shivanirmishra We will get this fix in the next possible servicing release. |
@saitama951 @fanyang-mono This is the profile with 100 iterations of some ml.net workload: ![]() This is the profile with 10k iterations of the same workload: ![]() The above profiles are after Any suggestions or ideas for why this is not working with larger overhead? |
@shivanirmishra I have proposed the fix for the issue that you were facing. |
Hi @saitama951 @fanyang-mono
Dimension of the matrix: 2000x3 and 3x2000, and running the MultiplyMatrices function once.
![]()
![]() We are not able to see the main function MultiplyMatrices anywhere in the profile. ![]() |
@shivanirmishra have you applied the diff changes ? |
@saitama951 Yes, It's working. |
This is related to #36774 . added support for
JIT_CODE_DEBUG_INFO
record which helps to annotate source code in perf.Changed the jitdump version to 1 as the perf sources expect version 1
https://github.com/torvalds/linux/blob/master/tools/perf/util/jitdump.h#L25
Example use:-
MONO_ENV_OPTIONS="--jitdump" perf record -k 1 dotnet <path/to/binary>
perf inject --jit -i perf.data -o perf.jit.data
perf report -i perf.jit.data
cc: @fanyang-mono