[Pythonmac-SIG] Performance on the Mac - A suggested fix

Jack Jansen jack@oratrix.nl
Thu, 21 Jun 2001 13:35:49 +0200


Recently, Gary Bringhurst <garyb@strata.com> said:
> In PyMac__DoIdle calls to WaitNextEvent are allowed to occur as often as
> requested, but this is a very expensive OS call.  A simple change would be
> to insert the following code:

Gary, very similar code to what you've added is already present in
PyErr_CheckSignals(), and that's the path that the interpreter
mainloop follows to get to PyMac_DoYield.

If your script really benefits from your mods to PyMac_DoYield (can
you measure to be sure?) there's two possibilities:
- You've messed around with MacOS.SchedParams() and set Python's
niceness to other apps to a too-high value.
- Your slowdown comes from PyMac_DoYield calls not from the mainloop
but from elsewhere. The only place I can think of is the GUSI I/O idle
loop: the I/O wait-for-completion routine eventually ends up in
PyMac_DoYield. If that is the case you've sped up some cases,
probably, but seriously slowed down others (talking to a local
webserver comes to mind).

If the second case is what's happening to you I'd be interested in
what sort of I/O you're doing. I can only imagine patterns like doing
raw I/O in very small chunks to cause this behaviour. But: I've never
really bothered testing Python I/O performance, so you could
definitely be on to something here.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm