[htop-general] Where can someone submit patches to htop?
Brought to you by:
loderunner
From: <ma...@gr...> - 2007-08-15 22:22:28
|
I have made a patch against 0.6.6 which adds a new field "URES", which =20 attempts to give a more clear picture of how much memory each app is =20 using. It might not be for everyone, so I may just keep this patch and =20 move it along. See http://koltsoff.com/pub/ures/ for an understanding of what URES =20 attempts to show. Current applications like "top" and "free" (and to some extent "htop") =20 mis-report how much memory an application is using. This is due mostly =20 to the fact that the kernel is very mysterious about memory usage, =20 making accurate page information difficult to report. URES is a value =20 that attempts to infer more accurate memory usage per process. I normally wouldn't like to use a a rough estimate of memory usage, =20 but vmsize and others are already wildly inaccurate metrics (they =20 vastly over-estimate RAM usage), so URES attempts to be more sensible =20 (although it tends to under-estimate in some race conditions). Until we have page-level accounting from the kernel, URES might be of =20 benefit to others. The patches are supplied below. Cheers, -matt groener, Engineering Computing, Intel, Inc. (my comments are my own; I do not speak for or represent my employer) =3D=3D=3D=3D PATCH =3D=3D=3D=3D --- htop-0.6.6/Process.c 2007-05-21 12:18:08.000000000 -0700 +++ htop-modified/Process.c 2007-08-15 13:15:13.000000000 -0700 @@ -43,3 +43,3 @@ PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, =20 M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, - USER, TIME, NLWP, LAST_PROCESSFIELD + USER, TIME, NLWP, URES, LAST_PROCESSFIELD } ProcessField; @@ -102,2 +102,3 @@ int m_share; + int ures; int m_trs; @@ -121,3 +122,3 @@ char *Process_fieldNames[] =3D { - "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", =20 "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", =20 "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", =20 "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", =20 "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", =20 "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", =20 "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", =20 "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", =20 "TIME", "NLWP", "*** report bug! ***" + "", "PID", "Command", "STATE", "PPID", "PGRP", "SESSION", =20 "TTY_NR", "TPGID", "FLAGS", "MINFLT", "CMINFLT", "MAJFLT", "CMAJFLT", =20 "UTIME", "STIME", "CUTIME", "CSTIME", "PRIORITY", "NICE", =20 "ITREALVALUE", "STARTTIME", "VSIZE", "RSS", "RLIM", "STARTCODE", =20 "ENDCODE", "STARTSTACK", "KSTKESP", "KSTKEIP", "SIGNAL", "BLOCKED", =20 "SIGIGNORE", "SIGCATCH", "WCHAN", "NSWAP", "CNSWAP", "EXIT_SIGNAL", =20 "PROCESSOR", "M_SIZE", "M_RESIDENT", "M_SHARE", "M_TRS", "M_DRS", =20 "M_LRS", "M_DT", "ST_UID", "PERCENT_CPU", "PERCENT_MEM", "USER", =20 "TIME", "NLWP", "URES", "*** report bug! ***" }; @@ -327,2 +328,3 @@ case M_SIZE: Process_printLargeNumber(this, str, this->m_size * =20 PAGE_SIZE); return; + case URES: Process_printLargeNumber(this, str, this->ures * =20 PAGE_SIZE); return; case M_RESIDENT: Process_printLargeNumber(this, str, =20 this->m_resident * PAGE_SIZE); return; @@ -429,2 +431,4 @@ return (p1->nlwp - p2->nlwp); + case URES: + return ((p2->m_resident - p1->m_resident) - (p2->m_share - =20 p1->m_share)); default: @@ -463,2 +467,3 @@ case NLWP: return "NLWP "; + case URES: return "URES "; default: return "- "; --- htop-0.6.6/Process.h 2007-05-21 12:26:18.000000000 -0700 +++ htop-modified/Process.h 2007-08-15 13:15:14.000000000 -0700 @@ -45,3 +45,3 @@ PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, =20 M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, - USER, TIME, NLWP, LAST_PROCESSFIELD + USER, TIME, NLWP, URES, LAST_PROCESSFIELD } ProcessField; @@ -104,2 +104,3 @@ int m_share; + int ures; int m_trs; --- htop-0.6.6/ProcessList.c 2007-05-21 11:05:47.000000000 -0700 +++ htop-modified/ProcessList.c 2007-08-15 15:17:52.000000000 -0700 @@ -127,3 +127,3 @@ -static ProcessField defaultHeaders[] =3D { PID, USER, PRIORITY, NICE, =20 M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, =20 COMM, 0 }; +static ProcessField defaultHeaders[] =3D { PID, USER, PRIORITY, NICE, =20 URES, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, =20 TIME, COMM, 0 }; @@ -561,2 +561,6 @@ fclose(status); + /* Attempt to provide a more sensible approach to "unique =20 RES memory" + See http://koltsoff.com/pub/ures/ + */ + process->ures =3D (process->m_resident - process->m_share); if(num !=3D 7) --- htop-0.6.6/htop.c 2007-05-17 10:07:38.000000000 -0700 +++ htop-modified/htop.c 2007-08-15 13:12:57.000000000 -0700 @@ -465,2 +465,11 @@ } + case 'R': + { + refreshTimeout =3D 0; + pl->sortKey =3D URES; + pl->treeView =3D false; + settings->changed =3D true; + Panel_setRichHeader(panel, ProcessList_printHeader(pl)); + break; + } case 'U': |