lynxthecat / cake-autorate

Eliminate the excess latency and jitter terrorizing your 4G, 5G, LTE, Starlink or other variable rate connection!
https://www.bufferbloat.net
GNU General Public License v2.0
263 stars 24 forks source link

Some more bash optimizations #291

Closed rany2 closed 4 months ago

rany2 commented 4 months ago

The below changes reduces CPU usage by 0.5% on my X86 machine:

lynxthecat commented 4 months ago

I came across this:

https://lobste.rs/s/1l1t8f/bash_functions_are_better_than_i_thought

With some functions like log_msg() there are conditionals that are repeatedly (and unnecessarily) reevaluated. It might be beneficial to either (re)define the functions based on the conditionals on the initial script load and/or leverage formulations like ‘${function} argument(s)’ in which the function is changed in dependence upon the conditionals.

rany2 commented 4 months ago

@lynxthecat I've thought of this actually but got lazy. I'm not sure how beneficial it would be to do this but I could look into it

lynxthecat commented 4 months ago

Very nice changes! I am seeing more frequent and more prolonged dips down to 6% total CPU usage on my RT3200 now (as measured using atop 2 and hitting p):

image