From 496c3b98b14f1e2e24bff50382fa184a267fdcca Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 21 Mar 2017 15:55:54 -0700 Subject: 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. --- src/libvmon/vmon.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3