diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2017-03-21 15:55:54 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2017-03-21 15:55:54 -0700 |
commit | 496c3b98b14f1e2e24bff50382fa184a267fdcca (patch) | |
tree | 95b47b037b324eb63c38486488cd8cd33fa5a424 | |
parent | 7b523e7c50ba430e3b25438c3ac33eaa86549fc4 (diff) |
libvmon: shirt-circuit parse loop on final state
This trivial change eliminates the final EOF realization read() syscall on
every /proc file consumed for every process on every sample, which adds up.
-rw-r--r-- | src/libvmon/vmon.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libvmon/vmon.c b/src/libvmon/vmon.c index e7936b5..3cee869 100644 --- a/src/libvmon/vmon.c +++ b/src/libvmon/vmon.c @@ -355,11 +355,12 @@ _retry: #include "defs/proc_stat.def" default: /* we're finished parsing once we've fallen off the end of the symbols */ - break; + goto _out; /* this saves us the EOF read syscall */ } } } +_out: return changes ? SAMPLE_CHANGED : SAMPLE_UNCHANGED; } @@ -830,11 +831,12 @@ static sample_ret_t proc_sample_vm(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_vm #include "defs/proc_vm.def" default: /* we're finished parsing once we've fallen off the end of the symbols */ - break; + goto _out; /* this saves us the EOF read syscall */ } } } +_out: return changes ? SAMPLE_CHANGED : SAMPLE_UNCHANGED; } @@ -886,11 +888,12 @@ static sample_ret_t proc_sample_io(vmon_t *vmon, vmon_proc_t *proc, vmon_proc_io #include "defs/proc_io.def" default: /* we're finished parsing once we've fallen off the end of the symbols */ - break; + goto _out; /* this saves us the EOF read syscall */ } } } +_out: return changes ? SAMPLE_CHANGED : SAMPLE_UNCHANGED; } @@ -932,11 +935,12 @@ static sample_ret_t sys_sample_stat(vmon_t *vmon, vmon_sys_stat_t **store) #include "defs/sys_stat.def" default: /* we're finished parsing once we've fallen off the end of the symbols */ - break; + goto _out; /* this saves us the EOF read syscall */ } } } +_out: return changes ? SAMPLE_CHANGED : SAMPLE_UNCHANGED; } @@ -980,11 +984,12 @@ static sample_ret_t sys_sample_vm(vmon_t *vmon, vmon_sys_vm_t **store) #include "defs/sys_vm.def" default: /* we're finished parsing once we've fallen off the end of the symbols */ - break; + goto _out; /* this saves us the EOF read syscall */ } } } +_out: return changes ? SAMPLE_CHANGED : SAMPLE_UNCHANGED; } |