'read' pessimistically read(2)s one byte at a time, which can be quite
slow for large environments.
Suggested by: jilles
Differential D18481
rc.subr: Implement list_vars without using 'read' cem on Dec 7 2018, 10:35 PM. Authored by Tags None Referenced Files
Subscribers None
Details 'read' pessimistically read(2)s one byte at a time, which can be quite Suggested by: jilles Basic test: $ truss -f -o truss.log -- sh -c '. /etc/rc.subr ; list_vars SHELL\*' && rg read\\\( truss.log | wc -l SHELL SHELLCHECK_OPTS 3401 $ truss -f -o truss.log -- sh -c '. ./rc.subr ; list_vars SHELL\*' && rg read\\\( truss.log | wc -l SHELL SHELLCHECK_OPTS 63 Performance: $ /usr/bin/time sh -c '. ./rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 1.08 real 1.06 user 0.02 sys $ /usr/bin/time sh -c '. ./rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 1.09 real 1.06 user 0.03 sys $ /usr/bin/time sh -c '. ./rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 1.10 real 1.09 user 0.00 sys $ /usr/bin/time sh -c '. ./rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 1.06 real 1.06 user 0.00 sys $ /usr/bin/time sh -c '. /etc/rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 3.65 real 1.54 user 2.40 sys $ /usr/bin/time sh -c '. /etc/rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 3.69 real 1.49 user 2.49 sys $ /usr/bin/time sh -c '. /etc/rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 3.81 real 1.55 user 2.55 sys $ /usr/bin/time sh -c '. /etc/rc.subr ; for j in $(seq 20) ; do for i in $(seq 100) ; do list_vars SHELL\* ; done; done' >/dev/null 3.82 real 1.54 user 2.57 sys $ cat > postpatchms.dat 1060 1100 1090 ^D $ cat > prepatchms.dat 3820 3810 3690 ^D $ ministat -w 60 prepatchms.dat postpatchms.dat x prepatchms.dat + postpatchms.dat +------------------------------------------------------------+ | + x | |++ x x | |AM |AM|| +------------------------------------------------------------+ N Min Max Median Avg Stddev x 3 3690 3820 3810 3773.3333 72.341781 + 3 1060 1100 1090 1083.3333 20.81666 Difference at 95.0% confidence -2690 +/- 120.649 -71.2898% +/- 1.24902% (Student's t, pooled s = 53.2291) Loop enough times and it's measurable, even on 2017 amd64.
Diff Detail
Event Timeline
Comment Actions
|