Title | MP’s high CPU usage on Solaris | |
Author | Hua Peng, StataCorp |
When using Stata/MP under Solaris, users might notice increased CPU usage after executing a parallelized command. For example, on a two-processor SPARCv9 SunOS 5.9 system, using the Unix command top after
. sysuse auto . regress mpg price
will report that CPU usage is close to 50%; i.e., one of the two processors is 100% loaded even though Stata/MP is idle. On a four-processor system, a user might see 100% usage of three processors even when Stata/MP is not running anything.
Sun’s parallel library implementation intentionally behaves this way to improve performance on dedicated systems. According to Sun’s documentation:
“Currently, the starting thread of a program creates bound threads. Once created, these bound threads participate in executing the parallel part of a program (parallel loop, parallel region, etc.) and keep spin-waiting while the sequential part of the program ru"ns. These bound threads never sleep or stop until the program terminates. Having these threads spin-wait generally gives the best performance when a parallelized program runs on a dedicated system. However, threads that are spin-waiting use system resources.”
Hence, users will notice increased CPU usage for Stata/MP as soon as the program executes a parallelized task. The number of processors that will be 100% used is the number of threads minus 1.
This behavior can be controlled by an environment variable, SUNW_MP_THR_IDLE. Possible values include
spin | sleep[ns | nms]
The default value is spin, which gives the best performance on dedicated systems but uses system resources and may not be appropriate if the system is shared by multiple users and programs.
The other choice, sleep[ns | nms], puts the thread to sleep after spin-waiting n units. The wait unit can be seconds (s, the default unit) or milliseconds (ms), where 1s means one second, and 10ms means 10 milliseconds. sleep with no arguments puts the thread to sleep immediately after completing a parallel task.
Changing the value to sleep by using either
[user@host]$ export SUNW_MP_THR_IDLE=sleep
in sh/bash or
[user@host]$ setenv SUNW_MP_THR_IDLE sleep
in csh/tcsh will fix this problem.
Learn
Free webinars
NetCourses
Classroom and web training
Organizational training
Video tutorials
Third-party courses
Web resources
Teaching with Stata
© Copyright 1996–2024 StataCorp LLC. All rights reserved.
×
We use cookies to ensure that we give you the best experience on our website—to enhance site navigation, to analyze usage, and to assist in our marketing efforts. By continuing to use our site, you consent to the storing of cookies on your device and agree to delivery of content, including web fonts and JavaScript, from third party web services.
Cookie Settings
Last updated: 16 November 2022
StataCorp LLC (StataCorp) strives to provide our users with exceptional products and services. To do so, we must collect personal information from you. This information is necessary to conduct business with our existing and potential customers. We collect and use this information only where we may legally do so. This policy explains what personal information we collect, how we use it, and what rights you have to that information.
These cookies are essential for our website to function and do not store any personally identifiable information. These cookies cannot be disabled.
This website uses cookies to provide you with a better user experience. A cookie is a small piece of data our website stores on a site visitor's hard drive and accesses each time you visit so we can improve your access to our site, better understand how you use our site, and serve you content that may be of interest to you. For instance, we store a cookie when you log in to our shopping cart so that we can maintain your shopping cart should you not complete checkout. These cookies do not directly store your personal information, but they do support the ability to uniquely identify your internet browser and device.
Please note: Clearing your browser cookies at any time will undo preferences saved here. The option selected here will apply only to the device you are currently using.