Simple event-based profiling tool using chrome://tracing utility #4673
Conversation
This is pretty cool. |
RB_SYSTEM_EVENT_PROFILING_END(); | ||
RB_FINALIZE_EVENT_PROFILING_DEFAULT(); | ||
|
||
return ret; |
nobu
Jul 25, 2021
Member
Do these macros have to be placed in main
, not ruby_init
, ruby_cleanup
and so on?
Do these macros have to be placed in main
, not ruby_init
, ruby_cleanup
and so on?
DarkKowalski
Jul 25, 2021
Author
I've moved them into ruby.c:ruby_sysinit()
and eval.c:rb_ec_cleanup()
I've moved them into ruby.c:ruby_sysinit()
and eval.c:rb_ec_cleanup()
Why casting away |
Could you rebase/squash so that appveyor will run? |
Other trivial points:
|
I've removed casting in front of Do you know any auto format tool (or configurations) I can use to format it? Thanks. |
Sure. |
8511307
to
bdc157b
I'm using misc/ruby-style.el. Or the following
|
bdc157b
to
d77de60
https://www.gnu.org/software/indent/manual/html_node/indent_17.html There's no option named |
@@ -0,0 +1,175 @@ | |||
#ifndef USE_EVENT_PROFILING |
ko1
Aug 5, 2021
Contributor
This definitions should be in RUBY_EVENT_PROFILING_H
guard.
This definitions should be in RUBY_EVENT_PROFILING_H
guard.
|
||
#include "ruby/internal/config.h" | ||
|
||
#include "vm_core.h" |
ko1
Aug 5, 2021
Contributor
why do you need vm_core.h?
why do you need vm_core.h?
DarkKowalski
Aug 5, 2021
•
Author
To use GET_RACTOR()
Line 1777
in
d77de60
in select_profiling_event_list
and get_a_profiling_event_slot
To use GET_RACTOR()
Line 1777 in d77de60
in select_profiling_event_list
and get_a_profiling_event_slot
@@ -1584,6 +1585,11 @@ rb_ractor_main_setup(rb_vm_t *vm, rb_ractor_t *r, rb_thread_t *th) | |||
r->pub.self = TypedData_Wrap_Struct(rb_cRactor, &ractor_data_type, r); | |||
FL_SET_RAW(r->pub.self, RUBY_FL_SHAREABLE); | |||
ractor_init(r, Qnil, Qnil); | |||
|
|||
#if USE_EVENT_PROFILING |
ko1
Aug 5, 2021
Contributor
How about to provide a macro RB_RACTOR_INIT_...
BTW, the subject should be profiling, so RB_EVENT_PROFILING_RACTOR_INIT
is one idea.
How about to provide a macro RB_RACTOR_INIT_...
BTW, the subject should be profiling, so RB_EVENT_PROFILING_RACTOR_INIT
is one idea.
int max_call_stack_depth; | ||
} rb_event_profiling_config_t; | ||
|
||
typedef enum rb_profiling_event_phase |
ko1
Aug 5, 2021
Contributor
The file (component) name is event_profiling
, so the prefix can be rb_event_profiling_
.
rb_profiling_event_phase_t
-> rb_event_profiling_phase_t
.
BTW, rb_profiling_event_phase_t
is used only once in this patch, so you don't need to make new type.
The file (component) name is event_profiling
, so the prefix can be rb_event_profiling_
.
rb_profiling_event_phase_t
-> rb_event_profiling_phase_t
.
BTW, rb_profiling_event_phase_t
is used only once in this patch, so you don't need to make new type.
|
||
#else | ||
|
||
#define RB_EVENT_PROFILING_BEGIN() |
ko1
Aug 5, 2021
Contributor
How to use them?
How to use them?
#include "ruby/thread_native.h" | ||
#include "vm_core.h" | ||
|
||
#if USE_EVENT_PROFILING |
ko1
Aug 5, 2021
Contributor
all above include except event_profiling.h
should be in this #if
block.
all above include except event_profiling.h
should be in this #if
block.
d77de60
to
02fb16e
02fb16e
to
f0db22f
Notice: Only has been tested on Linux as it uses
unistd.h
Inspired by @ko1
He advised me to use chrome://tracing to profile MRI's C Level behaviors
How to use
Enable it
Setup your configuration or just use the default
Profile a part of MRI
Test it (this case is provided by @dsh0416 )
make run
will produce a file namedevent_trace_out.json
by default, then open chrome://tracing and load it.Result:
