On 2013-11-09 21:27, Bastian Bittorf wrote: > i recognized that a "simple" 'ifup lan' can be > very expensive for a router with low ressources, > below a typcal call/execution trace: > > hotplug-call: $1 = 'iface' START: 1139 > hotplug-call: $1 = 'net' START: 1141 > hotplug-call: script: /etc/hotplug.d/iface/00-netstate START: 1139 > hotplug-call: script: /etc/hotplug.d/net/00-sysctl START: 1141 > hotplug-call: script: /etc/hotplug.d/iface/00-netstate READY: 1139 > hotplug-call: script: /etc/hotplug.d/net/00-sysctl READY: 1141 > hotplug-call: script: /etc/hotplug.d/iface/15-teql START: 1139 > hotplug-call: script: /etc/hotplug.d/net/99-batman-adv START: 1141 > hotplug-call: script: /etc/hotplug.d/iface/30-6relay START: 1139 > hotplug-call: script: /etc/hotplug.d/net/99-batman-adv READY: 1141 > hotplug-call: $1 = 'net' READY: 1141 > hotplug-call: $1 = 'net' START: 1168 > hotplug-call: script: /etc/hotplug.d/net/00-sysctl START: 1168 > hotplug-call: script: /etc/hotplug.d/net/00-sysctl READY: 1168 > hotplug-call: script: /etc/hotplug.d/net/99-batman-adv START: 1168 > hotplug-call: script: /etc/hotplug.d/net/99-batman-adv READY: 1168 > hotplug-call: $1 = 'net' READY: 1168 > hotplug-call: script: /etc/hotplug.d/iface/30-6relay READY: 1139 > hotplug-call: script: /etc/hotplug.d/iface/50-olsrd START: 1139 > hotplug-call: script: /etc/hotplug.d/iface/50-olsrd READY: 1139 > hotplug-call: $1 = 'iface' READY: 1139 > hotplug-call: $1 = 'iface' START: 1194 > hotplug-call: script: /etc/hotplug.d/iface/00-netstate START: 1194 > hotplug-call: script: /etc/hotplug.d/iface/00-netstate READY: 1194 > hotplug-call: script: /etc/hotplug.d/iface/15-teql START: 1194 > hotplug-call: script: /etc/hotplug.d/iface/15-teql READY: 1194 > hotplug-call: script: /etc/hotplug.d/iface/30-6relay START: 1194 > hotplug-call: script: /etc/hotplug.d/iface/30-6relay READY: 1194 > hotplug-call: script: /etc/hotplug.d/iface/50-olsrd START: 1194 > hotplug-call: script: /etc/hotplug.d/iface/50-olsrd READY: 1194 > hotplug-call: $1 = 'iface' READY: 1194 What do these numbers mean?
> we can see, that there a some calls to the shell-script '/sbin/hotplug-call' > with argument 'iface' or 'net' and the script itself sources again all > scripts found in the 'iface' or 'net'-folder. the calls for 'iface' > and 'net' run in parallel. (last number is process-id). It does not source all scripts into one context. For each script it forks, sources the script, and then the fork terminates. This should be quite efficient wrt. memory usage and run time. > is it really needed to run in parallel? maybe it can be made configurable > to run one after another? They are called from different processes, so they cannot easily be serialized. net is called by hotplug2 (on AA) / procd (on BB). iface is called by netifd. > i would like to send some optimizations, e.g. for the script > '/etc/hotplug.d/iface/00-netstate' we can change the external call > > sed -ne 's![^0-9].*$!!p' /proc/uptime > > to > > cut -d'.' -f1 /proc/uptime > > or even to use only internal calls: > > read UP REST </proc/up - and then use ${UP%.*} > > are the 'micro-optimizations' and nobody cares or is this ok? I'd like to avoid such micro-optimization churn unless you can prove that it actually matters. > fun fact: at the moment it can last several minutes on lowmem-routers > to do these easy tasks, because of the heavy forking/memory usage involved. It would be useful to figure out where all this memory is being eaten up. I don't see how these hotplug scripts are a significant source of memory usage. - Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel