On 2016-04-12 Matt Parlane wrote:
> I have compiled xz from source (rev ac398c3), and I am trying to use
> multithread compression by using -T 0 in the command line.
> 
> What I am finding is that when run straight from the command line, it
> uses multiple cores as expected. However, when running via a shell
> script via cron, only one core is utilised.
> 
> Any ideas? I'm running exactly the same command on the same file, and
> I would really love to make full use of my system.

Check if the environment variables XZ_DEFAULTS and XZ_OPT differ
between the two situations. I guess it's unlikely, but it's easy to
check, so I mentioned this first.

If the above didn't help: Does it work if you specify the number of
threads explicitly, for example, by using -T4 instead of -T0? If it
does, then the problem must be in the detection of the number of CPU
cores.

Since the detection works outside cron, perhaps there are some
restrictions that prevent it from working under cron. You didn't
mention your operating system or distribution, but I'm guessing
it's GNU/Linux. There xz uses sysconf(_SC_NPROCESSORS_ONLN) which makes
glibc read from /sys/devices/system/cpu/online. (I think it used to
read /proc/cpuinfo in the past.)

If something like SELinux blocks reading such files, then the core
count detection won't work. Compare the strace output in the two
situations:

    strace -o /home/foo/strace.txt xz -T0 < /dev/null > /dev/null

If it is a SELinux issue (or similar), it would be good to report it to
the distribution maintainers.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to