Skip to content

Use psutil to set process affinity (test_perf.py) + minor pylint-friendliness for ._ix #4296

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

Merged
merged 2 commits into from
Jul 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Optional dependencies

- `BeautifulSoup4`_ and `html5lib`_ (Any recent version of `html5lib`_ is
okay.)
- `BeautifulSoup4`_ and `lxml`_
- `BeautifulSoup4`_ and `html5lib`_ and `lxml`_
- `BeautifulSoup4`_ and `lxml`_
- `BeautifulSoup4`_ and `html5lib`_ and `lxml`_
- Only `lxml`_, although see :ref:`HTML reading gotchas <html-gotchas>`
for reasons as to why you should probably **not** take this approach.

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def axes(self):

@property
def ix(self):
if self._ix is None:
if self._ix is None: # defined in indexing.py; pylint: disable=E0203
self._ix = _SeriesIndexer(self, 'ix')

return self._ix
Expand Down
44 changes: 33 additions & 11 deletions vb_suite/test_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,15 @@
dest='hrepeats',
default=1,
type=int,
help='Implies -H, number of times to run the vbench suite on the head commit.\n'
'Each iteration will yield another column in the output.'
)
help='implies -H, number of times to run the vbench suite on the head commit.\n'
'Each iteration will yield another column in the output' )
parser.add_argument('-a', '--affinity',
metavar="a",
dest='affinity',
default=1,
type=int,
help='Set processor affinity of the process. THe default is to bind to cpu/core #1 only.'
'requires the "affinity" python module.' )

help='set processor affinity of process by default bind to cpu/core #1 only. '
'Requires the "affinity" or "psutil" python module, will raise Warning otherwise')
parser.add_argument('-u', '--burnin',
metavar="u",
dest='burnin',
Expand Down Expand Up @@ -388,14 +386,38 @@ def main():
random.seed(args.seed)
np.random.seed(args.seed)

affinity_set = False

# try psutil first since it is more commonly present and better
# maintained. Some people experienced problems with affinity package
# (see https://code.google.com/p/psutil/issues/detail?id=238 for more references)
try:
import affinity
affinity.set_process_affinity_mask(0,args.affinity)
assert affinity.get_process_affinity_mask(0) == args.affinity
print("CPU affinity set to %d" % args.affinity)
import psutil
if hasattr(psutil.Process, 'set_cpu_affinity'):
psutil.Process(os.getpid()).set_cpu_affinity([args.affinity])
affinity_set = True
except ImportError:
print("Warning: The 'affinity' module is not available.")
pass

if not affinity_set:
try:
import affinity
affinity.set_process_affinity_mask(0, args.affinity)
assert affinity.get_process_affinity_mask(0) == args.affinity
affinity_set = True
except ImportError:
pass

if not affinity_set:
import warnings
warnings.warn("\n\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"The 'affinity' or 'psutil' >= 0.5.0 modules are not available, results may be unreliable\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n"
)
time.sleep(2)
else:
print("CPU affinity set to %d" % args.affinity)

print("\n")
prprint("LOG_FILE = %s" % args.log_file)
Expand Down