pyglet CPU usage on Windows after importing

78 views
Skip to first unread message

Andrew York

unread,
Nov 22, 2015, 3:32:53 PM11/22/15
to pyglet-users
Hello, I'm new to the community, but I'm a very happy pyglet user for some time now. I've asked a pyglet question on stack overflow:

I'm not familiar with pyglet's internals, but I'm happy to do what I can to help answer this question.

Thanks for making this excellent project.

Benjamin Moran

unread,
Nov 23, 2015, 1:52:48 AM11/23/15
to pyglet-users
Hi Andrew,

You're on Windows 7, right? I just gave this a try on my Windows VM and could not replicate it. According to Windows Resource Monitor, the Python process CPU usage only blips up for a split second, then drops back down to 0%.

I tested on Win 7 Ultimate 64-bit, using the current default pyglet branch. If you're using the last stable pyglet release, could you give it a try with the lasted code from Bitbucket? 

-Ben

Andrew York

unread,
Nov 25, 2015, 5:07:41 PM11/25/15
to pyglet...@googlegroups.com, benmo...@gmail.com
Thanks for the response! Sorry for my delayed reply.

We're using Python 3 on Windows 7, our python distribution is Anaconda. My previous test used the pyglet installed by "pip install pyglet", which I believe installed 1.2.4

To test your suggestion, we created a virtual environment, and tried installing from the source instead of the latest stable 1.2.4. To do this, we used the following two commands:

conda create -n pyglettest python=3.4

Trying to import pyglet failed, unless my working directory was the directory where I had cloned the repository. It seems that pip install is not putting all of the repo into site packages in the way that I'd expect; in particular, the extlibs directory didn't contain future after pip install, but it was present in the repository. If I copied the future directory from extlibs into the place in site-packages where things were installed, then pyglet now imports.

Incidentally, setup.py for the repo shows a version of 1.3.0a, but pyglet/__init__.py sets pyglet.version = 1.2.2.

The high CPU usage following "import pyglet.image" still appeared to be present.

--
You received this message because you are subscribed to a topic in the Google Groups "pyglet-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyglet-users/20USjzHTy5g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Benjamin Moran

unread,
Nov 26, 2015, 10:31:21 PM11/26/15
to pyglet-users, benmo...@gmail.com
I gave this a try using Anaconda, and unfortunately wasn't able to replicate it. My Windows machine is just an old laptop with a dual core 64-bit Athlon and Windows 7. I'm not sure what else to recommend at this point, besides maybe trying on another Windows machine, or with a standalone Python installation (not Anaconda), though I don't know if that would make any difference. You may want to open a bug report on the bitbucket page as well, unless anyone else has any ideas.

Leif Theden

unread,
Nov 27, 2015, 12:36:06 AM11/27/15
to pyglet-users
On my windows 8.1, python 3.4.3, latest pyglet, I do not get this issue.  I did see a bump in CPU use, but it was short (1-2 seconds).  I imagine that it is related to the regular expressions in the class that are compiled with the class, but I am not certain without profiling it on your system.

https://bitbucket.org/pyglet/pyglet/src/531dca4475fd199d9097fc628614e68b8eeaa2ac/pyglet/image/__init__.py?at=default&fileviewer=file-view-default#__init__.py-624

This comes to mind:  The patient says, "Doctor, it hurts when I do this." Doctor says: "Then don't do that!"

 It could be your non-standard python distribution, CPU, compilers flags, cosmic rays, or that you are using the interactive prompt to make the problem happen.  Unless it happens under normal use (like running a pyglet app) and severely impacts your program, I don't see a problem here, IMO.

Andrew York

unread,
Nov 27, 2015, 7:11:38 PM11/27/15
to pyglet-users
 Thanks for checking that out, Benjamin.

 I tried a similar test (Anaconda/python 3.4 on a Windows 10 laptop, pyglet 1.2.4 installed through 'pip install pyglet'), there was only a short burst of CPU usage after typing pyglet.image.ImageData, so no apparent "bug" on that machine.

 On the Windows 7 desktop where I first encountered this unexpected behavior, I also tried out the most "standard" python install I could; (no anaconda, python 3.5 64-bit from python.org, followed by "pip install pyglet"). There was still high CPU usage following "import pyglet; pyglet.image.ImageData", whether from the REPL, or running a script in IDLE. This high CPU continues until I exit the IDLE shell or the python shell, long after the script has finished running, which seems strange to me.

 I don't know what debugging steps to try next, but I'm open to suggestions. is there anything rational I could try, or just try to check for the same unexpected behavior on more, different machines?

Andrew York

unread,
Nov 27, 2015, 7:25:47 PM11/27/15
to pyglet-users
 Thanks for trying that out, Leif. I get the same brief burst you describe on all the laptops I've tried this on, only my desktop gives the continuous high-CPU behavior.

 I agree, I'd love to take the "doctor's advice" and stop whatever mistake I'm making, since the high CPU usage badly impacts my project.

 Of course, it would be nice to know what to change (python version, python distro, pyglet version, OS, OS version, GPU, etc). So far, changing hardware seems to work (I've only gotten the bug on one machine), but changing software doesn't (different python versions and different pyglet versions don't seem to make a difference on that machine, as described above). Any further suggestions on what I might try would are greatly appreciated.

Leif Theden

unread,
Nov 28, 2015, 2:59:18 AM11/28/15
to pyglet-users
Does the high CPU happen if you ref. a different class in the same file (Like CompressedImageData, or others.)?  Can you use cProfile on that machine?
Reply all
Reply to author
Forward
0 new messages