My Python maxes out my cpus…

… And it’s just the unittest I wrote for an application I’m cooking up:

Picture 1.png

Python is consuming much in the way of processor time. I <3 the processing module. All the workers are doing is tossing integers from one queue to another (in, out, result) and doing random multiplication on those integers.

Delicious.

  • patrick
    It's pretty easy to max out your cpu if you never sleep to give the os some time. Even just this code will max things out, if you run enough processes to match your cpu count:

    while 1:
    pass
  • It's a bit of a joke - in this case, I am actually doing a unit test to ensure that the python application is fully leveraging the cores on the machine. A test I ran shortly thereafter on a 4 core box showed I could tap that out too with the workload.

    Functionally, the processing library is forking processes under the covers. The goal was not to max out for maxing out's sake, but rather to test an application which has to be able to cleanly and easily use al the cores on a box.
  • Stan
    Time for quad core!
  • Using my little test app, I could really abuse $N cores by simply increasing the worker count and workload - it scales as far as I need it to right now.
blog comments powered by Disqus