Skip to content

strange slowness of plot

6 messages · apjaworski@mmm.com, Duncan Murdoch, Brian Ripley +3 more

#
I just ran into this strange behavior.

     y <- rnorm(1000)
     x <- seq(0, length=length(y))

     plot(x, y, type='l', lty=1)   - instantaneous
     plot(x, y, type='l', lty=2)   - 18s plotting lines + 15s plotting axes
= 33s
     plot(x, y, type='l', lty=3)   - 76s          ,,               + 75s
,,            = 151s
     plot(x, y, type='l', lty=4)   - 40s          ,,               + 38s
,,            = 78s

A couple of observations:
(1) The plots for lty>1 seem to be rendered in "one chunk", that is a blank
graphics window appears and stays blank until all the lines appear at once.
Then another long wait for axes.
(2) While waiting for the plot, the computer becomes totally unresponsive.
Typical ctr-alt-del does nothing.  Even pushing the power button does
nothing.  I originally attempted the lty=2 plot with several hundred
thousand observations.  The only way I could get my machine back was to
disconnect the power cord!

My system is as follows:
(1) IBM Intellistation with PIII 1GHz, 512Mb of RDRAM, 20Gb SCSI160 drive,
64Mb FireGL graphics card
(2) Windows 2000 Pro
(3) R-1.3.0 (original version)

Andy

__________________________________
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-----
E-mail: apjaworski at mmm.com
Tel:  (651) 733-6092
Fax:  (651) 736-3122

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 24 Jul 2001 14:37:48 -0500, you wrote:

            
... and even longer times for other line types.

I tried this code on my tiny little Libretto (Pentium 120Mhz, 32Mb
ram, 20gb drive) running Win95, and it was noticeably slower doing the
line types other than type 1, but not nearly as slow as described.
I'd suggest you're short of some sort of graphics resource, or there's
a Win2K bug here.
Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 24 Jul 2001, Duncan Murdoch wrote:

            
I tried Windows 2000 and it is slo....ow.  If you time the function with
system.time (on NT/2000) you will see that 99+% of the time is system time.
And some checking shows that it is all being spent in the call to
StrokePath.  In other words, the slowness is in the Windows 2000 GDI and
not in R.  As Duncan points out, Windows 9x/ME has a different (mainly
16-bit) GDI and behaves differently (I tried Windows 98: 0.54 vs 0.09
secs as reported by system.time).

The issue is too the number of dashes needed.  Drawing a sensible dashed
curve on 1000 points (say around a circle) is not slow.  It looks like the
Windows 2000 GDI is very slow when asked to stroke many dashes: doubling
the number seems to take ca 7x longer.  This might be dependent on the
graphics card driver, as well as on the Windows version.

Also, it does not take 15secs to plot the axes.  What actually happens is
that the plot is done twice, first on screen then on a bitmap (for later
copying to a bitmap device?).  That suggests that the GDI per se is to
blame.

I need to talk to Guido, but it looks as if breaking the draw up into
smaller pieces will solve this.  On the other hand, it must have been there
for a couple of years, and no one has reported problems on a real plot yet.

  
    
#
Well, on Unix (and probably most other platforms), it's several orders of
magnitudes faster, *but* qualitatively similar :

Here are my findings (for a fast Linux on a not really fast graphics card):


## MM: User, System and Total
Ti <- function(expr) system.time(expr)[1:3]

## I just ran into this strange behavior.

N <- 1000 ## originally
N <- 100000# to see some slowness on Unix
y <- rnorm(N)
x <- 0:(N-1)
	                       ## Times : For N=1000, Andy Jaworski, see below
Ti(plot(x, y, type='l', lty=1))## instantaneous
Ti(plot(x, y, type='l', lty=2))## 18s plotting lines + 15s plotting axes =  33s
Ti(plot(x, y, type='l', lty=3))## 76s          ,,    + 75s       ,,      = 151s
Ti(plot(x, y, type='l', lty=4))## 40s          ,,    + 38s       ,,      =  78s

## MM : For N <- 100000, I get (on "lynne", a pretty new PIII)
##  User Sys  Total
##  ---- ---- ----
##  0.32 0.01 0.73
##  0.34 0.01 3.15
##  0.22 0.00 4.97
##  0.32 0.01 4.07
AndyJ> I just ran into this strange behavior.

    AndyJ> y <- rnorm(1000)
    AndyJ> x <- seq(0, length=length(y))

    AndyJ> plot(x, y, type='l', lty=1)   - instantaneous
    AndyJ> plot(x, y, type='l', lty=2)   - 18s plotting lines + 15s plotting axes
    AndyJ> = 33s
    AndyJ> plot(x, y, type='l', lty=3)   - 76s          ,,               + 75s
    AndyJ> ,,            = 151s
    AndyJ> plot(x, y, type='l', lty=4)   - 40s          ,,               + 38s
    AndyJ> ,,            = 78s

    AndyJ> A couple of observations:
    AndyJ> (1) The plots for lty>1 seem to be rendered in "one chunk", that is a blank
    AndyJ> graphics window appears and stays blank until all the lines appear at once.
    AndyJ> Then another long wait for axes.
    AndyJ> (2) While waiting for the plot, the computer becomes totally unresponsive.
    AndyJ> Typical ctr-alt-del does nothing.  Even pushing the power button does
    AndyJ> nothing.  I originally attempted the lty=2 plot with several hundred
    AndyJ> thousand observations.  The only way I could get my machine back was to
    AndyJ> disconnect the power cord!

    AndyJ> My system is as follows:
    AndyJ> (1) IBM Intellistation with PIII 1GHz, 512Mb of RDRAM, 20Gb SCSI160 drive,
    AndyJ> 64Mb FireGL graphics card
    AndyJ> (2) Windows 2000 Pro
    AndyJ> (3) R-1.3.0 (original version)

    AndyJ> Andy

    AndyJ> __________________________________
    AndyJ> Andy Jaworski
    AndyJ> Engineering Systems Technology Center
    AndyJ> 3M Center, 518-1-01
    AndyJ> St. Paul, MN 55144-1000
    AndyJ> -----
    AndyJ> E-mail: apjaworski at mmm.com
    AndyJ> Tel:  (651) 733-6092
    AndyJ> Fax:  (651) 736-3122

    AndyJ> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    AndyJ> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    AndyJ> Send "info", "help", or "[un]subscribe"
    AndyJ> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
    AndyJ> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
apjaworski> I just ran into this strange behavior.
    apjaworski> y <- rnorm(1000)
    apjaworski> x <- seq(0, length=length(y))

    apjaworski> plot(x, y, type='l', lty=1)   - instantaneous
    apjaworski> plot(x, y, type='l', lty=2)   - 18s plotting lines + 15s plotting axes
    apjaworski> = 33s
    apjaworski> plot(x, y, type='l', lty=3)   - 76s          ,,               + 75s
    apjaworski> ,,            = 151s
    apjaworski> plot(x, y, type='l', lty=4)   - 40s          ,,               + 38s
    apjaworski> ,,            = 78s

    apjaworski> A couple of observations:
    apjaworski> (1) The plots for lty>1 seem to be rendered in "one chunk", that is a blank
    apjaworski> graphics window appears and stays blank until all the lines appear at once.
    apjaworski> Then another long wait for axes.
    apjaworski> (2) While waiting for the plot, the computer becomes totally unresponsive.
    apjaworski> Typical ctr-alt-del does nothing.  Even pushing the power button does
    apjaworski> nothing.  I originally attempted the lty=2 plot with several hundred
    apjaworski> thousand observations.  The only way I could get my machine back was to
    apjaworski> disconnect the power cord!

    apjaworski> My system is as follows:
    apjaworski> (1) IBM Intellistation with PIII 1GHz, 512Mb of RDRAM, 20Gb SCSI160 drive,
    apjaworski> 64Mb FireGL graphics card
    apjaworski> (2) Windows 2000 Pro
    apjaworski> (3) R-1.3.0 (original version)

    apjaworski> Andy

    apjaworski> __________________________________
    apjaworski> Andy Jaworski
    apjaworski> Engineering Systems Technology Center
    apjaworski> 3M Center, 518-1-01
    apjaworski> St. Paul, MN 55144-1000
    apjaworski> -----
    apjaworski> E-mail: apjaworski at mmm.com
    apjaworski> Tel:  (651) 733-6092
    apjaworski> Fax:  (651) 736-3122

    apjaworski> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    apjaworski> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    apjaworski> Send "info", "help", or "[un]subscribe"
    apjaworski> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
    apjaworski> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I observed similar behavior with a Pentium III running NT4 SP6. 

For giggles, I tried the script in Splus; with lty = 2, the plotting was as
fast as with lty = 1. But for lty = 3 and lty =4,  the results were
similar.  Also, when the plot is being rendered, the system is completely
tied up. 

Anne

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anne E. York
National Marine Mammal Laboratory
Seattle WA 98115-0070  USA
e-mail: anne.york at noaa.gov
Voice: +1 206-526-4039
Fax: +1 206-526-6615
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Tue, 24 Jul 2001 apjaworski at mmm.com wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I've confirmed the same problem on another Win2k machine.

	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._