Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace loopsleepms with bash loadable #5368

Closed
wants to merge 1 commit into from
Closed

replace loopsleepms with bash loadable #5368

wants to merge 1 commit into from

Conversation

paulfantom
Copy link
Contributor

Summary

Simplify codebase by using bash loadable sleep for high-precision sleep instead of using custom shell wrapper.

Fixes #5161

Component Name

collectors/charts.d.plugin
collectors/tc.plugin

Additional Information

@netdatabot netdatabot added area/collectors Everything related to data collection area/external labels Feb 12, 2019
@paulfantom
Copy link
Contributor Author

review anyone?

@ktsaou
Copy link
Member

ktsaou commented Feb 25, 2019

The sleep bash module is not available everywhere.
For example, it is not available in our static binaries.

The result of the removal of loopsleepms will be 2 forks per second for tc-qos-helper.sh and charts.d.plugin.

loopsleepms uses several alternative methods to eliminate the need for these forks:

  1. /proc/uptime instead of external date
  2. bultin sleep instead of external sleep
  3. builtin read instead of external sleep

Issue #5161 is probably wrong. loopsleepms already uses the bash module when it is available:

if [ -z "${mysleep}" -a "$((BASH_VERSINFO[0] + 0))" -ge 3 -a "${NETDATA_BASH_LOADABLES}" != "DISABLE" ]; then
# enable modules only for bash version 3+
for bash_modules_path in ${BASH_LOADABLES_PATH//:/ } "$(pkg-config bash --variable=loadablesdir 2>/dev/null)" "/usr/lib/bash" "/lib/bash" "/lib64/bash" "/usr/local/lib/bash" "/usr/local/lib64/bash"; do
[ -z "${bash_modules_path}" -o ! -d "${bash_modules_path}" ] && continue
# check for sleep
for bash_module_sleep in "sleep" "sleep.so"; do
if [ -f "${bash_modules_path}/${bash_module_sleep}" ]; then
if enable -f "${bash_modules_path}/${bash_module_sleep}" sleep 2>/dev/null; then
mysleep="mysleep_builtin"
# echo >&2 "$0: Using bash loadable ${bash_modules_path}/${bash_module_sleep} for sleep"
break
fi
fi
done
[ ! -z "${mysleep}" ] && break
done
fi

@paulfantom paulfantom closed this Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/collectors Everything related to data collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tc.plugin: use high-precission bash sleep as loadable
3 participants