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

Spin locks causing hanging #41

hugbug opened this issue Jun 28, 2015 · 2 comments


None yet
1 participant
Copy link

commented Jun 28, 2015


A problem on Drobo NAS was reported. The program was sometimes hanging during par-repair when multithreading par-repair was active (option ParThreads).
After investigation it was found the program was hanging in the system function pthread_spin_lock.

The spin locks are alternative to mutexes and can provide performance gain in certain situations. In NZBGet spin locks are used only in two cases:

  • during par-repair if multicore par-repair is active - to synchronize repair threads;
  • if option AccurateRate is active - to synchronize download threads.

Spin locks can be always replaced by mutexes. Furthermore not all platforms support spin locks (for example Mac OS X doesn't and not every Linux system has them). NZBGet uses spin locks if available, otherwise it falls back to mutexes.

Steps to reproduce

Although the problem was initially reported during par-repair the easier way to reproduce is:

  • activate option AccurateRate;
  • download something.

If the system has problem with spin locks the download will soon stop.


  • deactivate the usage of spin locks in builds included in Linux installer;
  • investigate if spin locks provide any measurable performance gain in NZBGet;
  • if there are no any advantages - remove spin locks from the code.

@hugbug hugbug added this to the v16.0 milestone Jun 28, 2015


This comment has been minimized.

Copy link
Member Author

commented Jun 30, 2015

Made tests on a Linux box with mipsel CPU (2x400MHz). Don't see any performance gain when using spin locks. Quite the contrary- the mutex version downloads even faster.

@ftischhauser: could you please make a test on Windows?

  • activate option AccurateRate, download something and measure the speed and CPU usage;
  • then comment out "#define HAVE_SPINLOCK" in "daemon\windows\win32.h", recompile and measure again.

Are there any difference? Which is better?
Thank you.


This comment has been minimized.

Copy link
Member Author

commented Jul 15, 2015

Tested by @ftischhauser:

I can't tell any difference between these two builds with accurate rate turned on

Thanks for testing!

That means the support for spinlocks can be completely removed from the program as it doesn't bring any advantages.

hugbug added a commit that referenced this issue Jul 17, 2015

#41: removed spin lock support detection
from configure script (POSIX).

hugbug added a commit that referenced this issue Jul 17, 2015

@hugbug hugbug closed this Jul 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.