Skip to content
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
3 changes: 3 additions & 0 deletions .release-notes/4620.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Fix incorrect printing of runtime stats

When the runtime was compiled with the runtime stats option on, some stats were being printed to standard out without them having been requested. We've fixed the issue so stats will only be printed if the option is turned on by the user.
3 changes: 2 additions & 1 deletion src/libponyrt/actor/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ void ponyint_actor_destroy(pony_actor_t* actor)
ctx->schedulerstats.mem_used_actors -= actor->type->size;
ctx->schedulerstats.mem_allocated_actors -= ponyint_pool_used_size(actor->type->size);
ctx->schedulerstats.destroyed_actors_counter++;
print_actor_stats(actor);
if (ponyint_sched_print_stats())
print_actor_stats(actor);
#endif

// Free variable sized actors correctly.
Expand Down
20 changes: 14 additions & 6 deletions src/libponyrt/sched/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ void print_scheduler_stats(scheduler_t* sched)
);
}

/* Get whether stat printing is on */
bool ponyint_sched_print_stats()
{
return print_stats;
}

/** Get the static memory used by the scheduler subsystem.
*/
size_t ponyint_sched_static_mem_size()
Expand Down Expand Up @@ -1134,7 +1140,7 @@ static void run(scheduler_t* sched)
while(true)
{
#ifdef USE_RUNTIMESTATS
if(print_stats)
if(ponyint_sched_print_stats())
{
// convert to cycles for use with ponyint_cpu_tick()
// 1 second = 2000000000 cycles (approx.)
Expand Down Expand Up @@ -1219,7 +1225,8 @@ static void run(scheduler_t* sched)
#ifdef USE_RUNTIMESTATS
uint64_t used_cpu = ponyint_sched_cpu_used(&sched->ctx);
sched->ctx.schedulerstats.misc_cpu += used_cpu;
print_scheduler_stats(sched);
if(ponyint_sched_print_stats())
print_scheduler_stats(sched);
#endif

// Termination.
Expand Down Expand Up @@ -1427,7 +1434,7 @@ static void run_pinned_actors()
while(true)
{
#ifdef USE_RUNTIMESTATS
if(print_stats)
if(ponyint_sched_print_stats())
{
// convert to cycles for use with ponyint_cpu_tick()
// 1 second = 2000000000 cycles (approx.)
Expand All @@ -1454,8 +1461,9 @@ static void run_pinned_actors()
if(sched->terminate)
{
#ifdef USE_RUNTIMESTATS
uint64_t used_cpu = ponyint_sched_cpu_used(&sched->ctx);
sched->ctx.schedulerstats.misc_cpu += used_cpu;
uint64_t used_cpu = ponyint_sched_cpu_used(&sched->ctx);
sched->ctx.schedulerstats.misc_cpu += used_cpu;
if(ponyint_sched_print_stats())
print_scheduler_stats(sched);
#endif

Expand Down Expand Up @@ -1484,7 +1492,7 @@ static void run_pinned_actors()
uint64_t clocks_elapsed = tsc2 - tsc;

// We had an empty queue and no actor. need to suspend or sleep only if
// mutemap is empty as this thread doesn't participate in work stealing
// mutemap is empty as this thread doesn't participate in work stealing
if(ponyint_mutemap_size(&sched->mute_mapping) == 0 && clocks_elapsed > scheduler_suspend_threshold)
{
// suspend
Expand Down
2 changes: 2 additions & 0 deletions src/libponyrt/sched/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void ponyint_sched_maybe_wakeup(int32_t current_scheduler_id);
void ponyint_sched_maybe_wakeup_if_all_asleep(int32_t current_scheduler_id);

#ifdef USE_RUNTIMESTATS
bool ponyint_sched_print_stats();

uint64_t ponyint_sched_cpu_used(pony_ctx_t* ctx);

/** Get the static memory used by the scheduler subsystem.
Expand Down