@@ -997,24 +997,29 @@ void RAI_moduleInfoFunc(RedisModuleInfoCtx *ctx, int for_crash_report) {
997
997
RedisModule_InfoAddFieldLongLong (ctx , "inter_op_parallelism" , getBackendsInterOpParallelism ());
998
998
RedisModule_InfoAddFieldLongLong (ctx , "intra_op_parallelism" , getBackendsIntraOpParallelism ());
999
999
struct rusage self_ru , c_ru ;
1000
-
1000
+
1001
1001
// Return resource usage statistics for the calling process,
1002
1002
// which is the sum of resources used by all threads in the
1003
1003
// process
1004
1004
getrusage (RUSAGE_SELF , & self_ru );
1005
1005
1006
- // Return resource usage statistics for the calling thread
1007
- // which in this case is Redis/RedisAI main thread
1008
- // RUSAGE_THREAD is Linux-specific.
1006
+ // Return resource usage statistics for the calling thread
1007
+ // which in this case is Redis/RedisAI main thread
1008
+ // RUSAGE_THREAD is Linux-specific.
1009
+ sds main_thread_used_cpu_sys = sdsempty ();
1010
+ sds main_thread_used_cpu_user = sdsempty ();
1009
1011
#if (defined(__linux__ ) && defined(RUSAGE_THREAD ))
1010
1012
struct rusage main_thread_ru ;
1011
1013
getrusage (RUSAGE_THREAD , & main_thread_ru );
1012
- sds main_thread_used_cpu_user =
1013
- sdscatprintf (sdsempty () , "%ld.%06ld" , (long )main_thread_ru .ru_stime .tv_sec ,
1014
+ main_thread_used_cpu_sys =
1015
+ sdscatprintf (main_thread_used_cpu_sys , "%ld.%06ld" , (long )main_thread_ru .ru_stime .tv_sec ,
1014
1016
(long )self_ru .ru_stime .tv_usec );
1015
- sds main_thread_used_cpu_sys =
1016
- sdscatprintf (sdsempty () , "%ld.%06ld" , (long )main_thread_ru .ru_utime .tv_sec ,
1017
+ main_thread_used_cpu_user =
1018
+ sdscatprintf (main_thread_used_cpu_user , "%ld.%06ld" , (long )main_thread_ru .ru_utime .tv_sec ,
1017
1019
(long )self_ru .ru_utime .tv_usec );
1020
+ #else
1021
+ sdscatprintf (main_thread_used_cpu_sys , "N/A" );
1022
+ sdscatprintf (main_thread_used_cpu_user , "N/A" );
1018
1023
#endif
1019
1024
1020
1025
// Return resource usage statistics for all of its
@@ -1033,10 +1038,9 @@ void RAI_moduleInfoFunc(RedisModuleInfoCtx *ctx, int for_crash_report) {
1033
1038
RedisModule_InfoAddFieldCString (ctx , "self_used_cpu_user" , self_used_cpu_user );
1034
1039
RedisModule_InfoAddFieldCString (ctx , "children_used_cpu_sys" , children_used_cpu_sys );
1035
1040
RedisModule_InfoAddFieldCString (ctx , "children_used_cpu_user" , children_used_cpu_user );
1036
- #if (defined(__linux__ ) && defined(RUSAGE_THREAD ))
1037
1041
RedisModule_InfoAddFieldCString (ctx , "main_thread_used_cpu_sys" , main_thread_used_cpu_sys );
1038
1042
RedisModule_InfoAddFieldCString (ctx , "main_thread_used_cpu_user" , main_thread_used_cpu_user );
1039
- #endif
1043
+
1040
1044
AI_dictIterator * iter = AI_dictGetSafeIterator (run_queues );
1041
1045
AI_dictEntry * entry = AI_dictNext (iter );
1042
1046
while (entry ) {
0 commit comments