isolver / ioHub

A Python program, running as an independent process, that provides a 'proxy like' service for experiment runtimes ( psychopy ) and devices ( keyboard, mouse, parallel port, eye tracker, ... ).
19 stars 14 forks source link

Takes very long ( 5 - 10 seconds ) for experiment to start #63

Closed isolver closed 11 years ago

isolver commented 11 years ago

On my max mini, when I start the simple demo for example, it takes between 5 - 10 seconds for the experiment to start. Compare this to < 1 second on Windows and Linux.

Look into why this is and what can be done to fix it, as the start up time is unacceptable right now IMO.

I think it is related to the Quartz event hooks being brought online.

It may also have to do with the pyYAML on OSX not using the C backend library and running in pure python on my Mac, which is much much slower for the YAML parser I guess. Anyone have pyYAML running with libYaml on the backend; is your startup time slow??

isolver commented 11 years ago

Timed the Quartz event init. Stuff and it takes about 50 msec, so that if not the source of the slowness. That leaves the non optimized YAML as a prime suspect, as everything else is the same on the other OSs and we know it is not python itself being slower.

jeremygray commented 11 years ago

I'll report back once I get libyaml working, its not currently working for me

isolver commented 11 years ago

I figured out how to get libyaml and pyYAML working. If you install libyaml using homebrew:

brew install libyaml --universal

Then it builds a 32bit version of the library, which was the issue before for me. Be sure to use the --universal flag with the brew install, otherwise it defaults to installing only 64bit, which is what I think the standard make process was doing for libyaml.

Once that is installed, reinstall pyyaml with the command:

python setup.py --with-libyaml install

Then you no longer get the message that pyYAML is using the Python based parser etc.

HOWEVER, it still takes 10 seconds or so for the session info dialog to appear after I run:

python run.py

using the simple example in the iohub/examples dir.

So it does not seem to be pyYAML that is the source of the slowness, and the Quartz time is fast, so I do not know what it is that causes the script start to session dialog time to be so long on OSX when Linux and Winodows are fast.

As another note, Jon mentioned that it only takes a second for the script to run on his OS X box; so why are Jeremy and I seeing very long load times and Jon now; Jon do you have a super Apple hardware config or something?

isolver commented 11 years ago

Seems like the culprit was the combination of using "import" for dynamically loading the device modules + having a

from Quartz import *

in the iohub.devices.mouse darwin.py implementation. I removed the sloppy import * and now examples load in 1 second or less on my OS X mac mini.