Skip to content

Commit

Permalink
Update dtrace probes
Browse files Browse the repository at this point in the history
A user opened #4296 and noted that the probes were out of date. The
names of @params in comments need to match the names in the function
definitions.

While exploring the issue, I found that some functions lacked param
definitions, some had missing params, some had misnamed params, and some
functions were lacking useful information such as the actor in being run
where only the scheduler was present and the actor is the most useful
bit of information.

This commit fixes all the issues I found and in the process closes the
original issue.

Fixes #4296
  • Loading branch information
SeanTAllen committed Jan 13, 2023
1 parent 2e4e9e2 commit 626936e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
43 changes: 29 additions & 14 deletions src/common/dtrace_probes.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ provider pony {

/**
* Fired when a message is being run by an actor
* @params scheduler is the active scheduler
* @param actor the actor running the message
* @param id the message id
*/
probe actor__msg__run(uintptr_t scheduler, uintptr_t actor, uint32_t id);

/**
* Fired when a message is being sent to an actor
* @param scheduler is the active scheduler's index
* @param scheduler_index is the active scheduler's index
* @param id the message id
* @param actor_from is the sending actor
* @param actor_to is the receiving actor
Expand All @@ -33,7 +34,7 @@ provider pony {

/**
* Fired when a message is being run by an actor
* @param scheduler is the active scheduler's index
* @param scheduler_index is the active scheduler's index
* @param id the message id
* @param actor_to is the receiving actor
*/
Expand All @@ -42,15 +43,15 @@ provider pony {
/**
* Fired when a message is being sent to an thread
* @param id the message id
* @param thread_from is the sending thread index
* @param thread_to is the receiving thread index
* @param thread_from is the sending thread
* @param thread_to is the receiving thread
*/
probe thread__msg__push(uint32_t id, uintptr_t thread_from, uintptr_t thread_to);

/**
* Fired when a message is being run by an thread
* @param id the message id
* @param thread_to is the receiving thread index
* @param thread is the receiving thread
*/
probe thread__msg__pop(uint32_t id, uintptr_t thread);

Expand Down Expand Up @@ -112,33 +113,45 @@ provider pony {

/**
* Fired when the garbage collection function is ending
* @param scheduler is active scheduler
* @param actor is the actor that was garbage collecting
*/
probe gc__end(uintptr_t scheduler);
probe gc__end(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collector finishes sending an object
* @param scheduler is active scheduler
* @param actor is the actor that is finished sending
*/
probe gc__send__end(uintptr_t scheduler);
probe gc__send__end(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collector stats sending an object
* Fired when the garbage collector starts sending an object
* @param scheduler is active scheduler
* @param actor is the actor that is starting to send an object
*/
probe gc__send__start(uintptr_t scheduler);
probe gc__send__start(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collector finishes receiving an object
* @param scheduler is active scheduler
* @params actor is the actor that finished receiving an object
*/
probe gc__recv__end(uintptr_t scheduler);
probe gc__recv__end(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collector starts receiving an object
* @param scheduler is active scheduler
* @param actor is the actor that is receiving an object
*/
probe gc__recv__start(uintptr_t scheduler);
probe gc__recv__start(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collection function has started
* @param scheduler is active scheduler
* @param actor is the actor that was garbage collecting
*/
probe gc__start(uintptr_t scheduler);
probe gc__start(uintptr_t scheduler, uintptr_t actor);

/**
* Fired when the garbage collection threshold is changed with a certain factor
Expand All @@ -148,9 +161,11 @@ provider pony {

/**
* Fired when memory is allocated on the heap
* @param scheduler is active scheduler
* @param actor is the actor that is allocating memory
* @param size the size of the allocated memory
*/
probe heap__alloc(uintptr_t scheduler, unsigned long size);
probe heap__alloc(uintptr_t scheduler, uintptr_t actor, unsigned long size);

/**
* Fired when runtime initiates
Expand All @@ -169,7 +184,7 @@ provider pony {

/**
* Fired when a scheduler successfully steals a job
* @param scheduler is the scheduler that stole the job
* @param scheduler is active scheduler
* @param victim is the victim that the scheduler stole from
* @param actor is actor that was stolen from the victim
*/
Expand Down
18 changes: 9 additions & 9 deletions src/libponyrt/actor/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static void try_gc(pony_ctx_t* ctx, pony_actor_t* actor)
ctx->schedulerstats.misc_cpu += used_cpu;
#endif

DTRACE1(GC_START, (uintptr_t)ctx->scheduler);
DTRACE2(GC_START, (uintptr_t)ctx->scheduler, (uintptr_t)actor);

ponyint_gc_mark(ctx);

Expand All @@ -279,7 +279,7 @@ static void try_gc(pony_ctx_t* ctx, pony_actor_t* actor)
);
#endif

DTRACE1(GC_END, (uintptr_t)ctx->scheduler);
DTRACE2(GC_END, (uintptr_t)ctx->scheduler, (uintptr_t)actor);

#ifdef USE_RUNTIMESTATS
used_cpu = ponyint_sched_cpu_used(ctx);
Expand Down Expand Up @@ -1101,7 +1101,7 @@ PONY_API void pony_sendi(pony_ctx_t* ctx, pony_actor_t* to, uint32_t id,
PONY_API void* pony_alloc(pony_ctx_t* ctx, size_t size)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, size);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, size);

return ponyint_heap_alloc(ctx->current, &ctx->current->heap, size,
TRACK_NO_FINALISERS);
Expand All @@ -1110,7 +1110,7 @@ PONY_API void* pony_alloc(pony_ctx_t* ctx, size_t size)
PONY_API void* pony_alloc_small(pony_ctx_t* ctx, uint32_t sizeclass)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, HEAP_MIN << sizeclass);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, HEAP_MIN << sizeclass);

return ponyint_heap_alloc_small(ctx->current, &ctx->current->heap, sizeclass,
TRACK_NO_FINALISERS);
Expand All @@ -1119,7 +1119,7 @@ PONY_API void* pony_alloc_small(pony_ctx_t* ctx, uint32_t sizeclass)
PONY_API void* pony_alloc_large(pony_ctx_t* ctx, size_t size)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, size);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, size);

return ponyint_heap_alloc_large(ctx->current, &ctx->current->heap, size,
TRACK_NO_FINALISERS);
Expand All @@ -1128,15 +1128,15 @@ PONY_API void* pony_alloc_large(pony_ctx_t* ctx, size_t size)
PONY_API void* pony_realloc(pony_ctx_t* ctx, void* p, size_t size, size_t copy)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, size);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, size);

return ponyint_heap_realloc(ctx->current, &ctx->current->heap, p, size, copy);
}

PONY_API void* pony_alloc_final(pony_ctx_t* ctx, size_t size)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, size);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, size);

return ponyint_heap_alloc(ctx->current, &ctx->current->heap, size,
TRACK_ALL_FINALISERS);
Expand All @@ -1145,7 +1145,7 @@ PONY_API void* pony_alloc_final(pony_ctx_t* ctx, size_t size)
void* pony_alloc_small_final(pony_ctx_t* ctx, uint32_t sizeclass)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, HEAP_MIN << sizeclass);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, HEAP_MIN << sizeclass);

return ponyint_heap_alloc_small(ctx->current, &ctx->current->heap,
sizeclass, TRACK_ALL_FINALISERS);
Expand All @@ -1154,7 +1154,7 @@ void* pony_alloc_small_final(pony_ctx_t* ctx, uint32_t sizeclass)
void* pony_alloc_large_final(pony_ctx_t* ctx, size_t size)
{
pony_assert(ctx->current != NULL);
DTRACE2(HEAP_ALLOC, (uintptr_t)ctx->scheduler, size);
DTRACE3(HEAP_ALLOC, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current, size);

return ponyint_heap_alloc_large(ctx->current, &ctx->current->heap,
size, TRACK_ALL_FINALISERS);
Expand Down
8 changes: 4 additions & 4 deletions src/libponyrt/gc/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PONY_API void pony_gc_send(pony_ctx_t* ctx)
ctx->trace_object = ponyint_gc_sendobject;
ctx->trace_actor = ponyint_gc_sendactor;

DTRACE1(GC_SEND_START, (uintptr_t)ctx->scheduler);
DTRACE2(GC_SEND_START, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current);
}

PONY_API void pony_gc_recv(pony_ctx_t* ctx)
Expand All @@ -23,7 +23,7 @@ PONY_API void pony_gc_recv(pony_ctx_t* ctx)
ctx->trace_object = ponyint_gc_recvobject;
ctx->trace_actor = ponyint_gc_recvactor;

DTRACE1(GC_RECV_START, (uintptr_t)ctx->scheduler);
DTRACE2(GC_RECV_START, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current);
}

void ponyint_gc_mark(pony_ctx_t* ctx)
Expand Down Expand Up @@ -56,7 +56,7 @@ PONY_API void pony_send_done(pony_ctx_t* ctx)
ponyint_gc_sendacquire(ctx);
ponyint_gc_done(ponyint_actor_gc(ctx->current));

DTRACE1(GC_SEND_END, (uintptr_t)ctx->scheduler);
DTRACE2(GC_SEND_END, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current);
}

PONY_API void pony_recv_done(pony_ctx_t* ctx)
Expand All @@ -65,7 +65,7 @@ PONY_API void pony_recv_done(pony_ctx_t* ctx)
ponyint_gc_handlestack(ctx);
ponyint_gc_done(ponyint_actor_gc(ctx->current));

DTRACE1(GC_RECV_END, (uintptr_t)ctx->scheduler);
DTRACE2(GC_RECV_END, (uintptr_t)ctx->scheduler, (uintptr_t)ctx->current);
}

void ponyint_mark_done(pony_ctx_t* ctx)
Expand Down

0 comments on commit 626936e

Please # to comment.