Skip to content

Commit 9f37c6a

Browse files
i#7504 time scale: Add stats on drx scaling (#7594)
Records and provides statistics on the counts of scaling attempts, failures, and nops for each class of operations that are scaled. Adds testing of the new interface. Issue: #7504
1 parent ec6d510 commit 9f37c6a

File tree

6 files changed

+226
-34
lines changed

6 files changed

+226
-34
lines changed

ext/drx/drx.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,40 @@ typedef struct _drx_time_scale_t {
574574
uint timeout_scale;
575575
} drx_time_scale_t;
576576

577+
/** Application action types for #drx_time_scale_stat_t. */
578+
typedef enum {
579+
DRX_SCALE_ITIMER, /**< Any of the 3 itimers. */
580+
DRX_SCALE_POSIX_TIMER, /**< Any POSIX timer. */
581+
DRX_SCALE_SLEEP, /**< Any sleep system call. */
582+
DRX_SCALE_STAT_TYPES, /**< Count of stat types. */
583+
} drx_time_scale_type_t;
584+
585+
/**
586+
* Statistics on scaling attempts for one application action type.
587+
*/
588+
typedef struct _drx_time_scale_stat_t {
589+
/* Since dr_atomic_add64_return_sum() is not supported for 32-bit, we make
590+
* the counters match the bitwidth.
591+
* An alternative would be to use thread-local counters, but we have no
592+
* simple way to aggregate all threads prior to exit time.
593+
*/
594+
/**
595+
* Count of the instances that might need scaling.
596+
* For timers, this counts the initial value and the interval separately.
597+
* If #count_failed and #count_nop are subtracted from this, the result
598+
* is the count that were successfully scaled to a larger duration.
599+
*/
600+
ptr_int_t count_attempted;
601+
/**
602+
* Count of the instances where scaling was attempted but failed.
603+
*/
604+
ptr_int_t count_failed;
605+
/**
606+
* Count of the instances ignored (disabled timers, sleep of 0, scale of 1, etc.).
607+
*/
608+
ptr_int_t count_nop;
609+
} drx_time_scale_stat_t;
610+
577611
/**
578612
* Priorities of drmgr instrumentation passes used for time scaling. Users can use these
579613
* priorities in the #drmgr_priority_t "priority" field or the associated names
@@ -622,6 +656,15 @@ DR_EXPORT
622656
bool
623657
drx_unregister_time_scaling();
624658

659+
DR_EXPORT
660+
/**
661+
* Returns a pointer to an array with #DRX_SCALE_STAT_TYPES entries, with the entry
662+
* at index "i" containing statistics on scaling for the #drx_time_scale_type_t with
663+
* value equal to "i".
664+
*/
665+
bool
666+
drx_get_time_scaling_stats(drx_time_scale_stat_t **stats_array);
667+
625668
/**@}*/ /* end doxygen group */
626669

627670
#ifdef __cplusplus

0 commit comments

Comments
 (0)