[racket] gracket 5.0.1.2 performance on OS X

From: Jakub Piotr Cłapa (jpc-ml at zenburn.net)
Date: Tue Aug 10 14:06:52 EDT 2010

I was trying to add a GUI windows to my small Racket program for 
debugging embedded systems. It was super easy and worked like charm the 
first time (thanks!) but unfortunately I found great performance 
degradation under gracket.

AFAICT the problem boils down to reading data from a subprocess. Even 
when I throw away the data I get 0,5% CPU usage in racket and 55% in 
gracket (without any GUI windows open). I attached a minimal example 
that shows the problem (the rkt program runs the shell script and reads 
it's output) for which I get the following:

[jpc at jpc racket] time racket test.rkt >| /dev/null
racket test.rkt >| /dev/null  4.82s user 16.61s system 64% cpu 33.251 total
[jpc at jpc racket] time gracket test.rkt >| /dev/null
gracket test.rkt >| /dev/null  13.70s user 27.27s system 113% cpu 36.039 
total

And the baseline:

[jpc at jpc racket] time ./test.sh >| /dev/null
./test.sh >| /dev/null  4.19s user 15.85s system 61% cpu 32.854 total

I get 50-60% CPU usage by gracket in the Activity Monitor versus 2,5% in 
racket.

A quick Activity Monitor investigation revealed that the gracket version 
made around 10x more UNIX system calls and more than 1000x more Mach 
messages/system calls. The amount of context switches is also much 
higher in gracket.

The behaviour stops as soon as I remove the "sleep .001" from the shell 
script (so it outputs data in big chunks). It looks to me like the event 
loop and racket thread scheduling is not working very well in the GUI 
version of racket.

PS. I did not test older versions since I do not have them installed 
right now but I am happy to do any additional tests you think may be 
helpful.

-- 
regards,
Jakub Piotr Cłapa
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.rkt
URL: <http://lists.racket-lang.org/users/archive/attachments/20100810/105fc675/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sh
Type: application/x-sh
Size: 85 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100810/105fc675/attachment.sh>

Posted on the users mailing list.