Print some rusage info in debug

This commit is contained in:
Yury Selivanov 2015-11-26 16:39:28 -05:00
parent c300da7cee
commit cce6f3bb77
2 changed files with 48 additions and 3 deletions

View File

@ -445,11 +445,29 @@ cdef class Loop:
IF DEBUG:
def print_debug_info(self):
print('\n--- Loop debug info: ---')
cdef:
int err
uv.uv_rusage_t rusage
err = uv.uv_getrusage(&rusage)
if err < 0:
raise convert_error(err)
################### OS
print('---- Process info: -----')
print('Process memory: ', rusage.ru_maxrss)
print('Number of signals: ', rusage.ru_nsignals)
print('')
################### Loop
print('--- Loop debug info: ---')
print('Loop time: {}'.format(self.time()))
print()
print('UVHandles (current | total):')
for name in sorted(self._debug_handles_total):
print(' {: <18}: {: >5} | {}'.format(
print(' {: <18} {: >5} | {}'.format(
name,
self._debug_handles_count[name],
self._debug_handles_total[name]))
@ -468,7 +486,8 @@ cdef class Loop:
self._debug_cb_timer_handles_total))
print()
print('------------------------\n', flush=True)
print('------------------------')
print(flush=True)
def __repr__(self):
return ('<%s running=%s closed=%s debug=%s>'

View File

@ -267,3 +267,29 @@ cdef extern from "../vendor/libuv/include/uv.h":
uv_os_sock_t socket)
int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb)
int uv_poll_stop(uv_poll_t* poll)
# Misc
ctypedef struct uv_timeval_t:
long tv_sec
long tv_usec
ctypedef struct uv_rusage_t:
uv_timeval_t ru_utime # user CPU time used
uv_timeval_t ru_stime # system CPU time used
uint64_t ru_maxrss # maximum resident set size
uint64_t ru_ixrss # integral shared memory size
uint64_t ru_idrss # integral unshared data size
uint64_t ru_isrss # integral unshared stack size
uint64_t ru_minflt # page reclaims (soft page faults)
uint64_t ru_majflt # page faults (hard page faults)
uint64_t ru_nswap # swaps
uint64_t ru_inblock # block input operations
uint64_t ru_oublock # block output operations
uint64_t ru_msgsnd # IPC messages sent
uint64_t ru_msgrcv # IPC messages received
uint64_t ru_nsignals # signals received
uint64_t ru_nvcsw # voluntary context switches
uint64_t ru_nivcsw # involuntary context switches
int uv_getrusage(uv_rusage_t* rusage)