[racket] disable garbage collection

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Jun 7 21:16:35 EDT 2011

On Fri, Jun 3, 2011 at 9:18 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> You can now set the PLTDISABLEGC environment variable before startup to
> disable GC.

For my own amusement, I went and found a program that behaves worse
when the GC is disabled. Here's what I got (I ran my timings under
windows 7):

with GC off:

cpu time: 609 real time: 606 gc time: 0
cpu time: 610 real time: 604 gc time: 0
cpu time: 625 real time: 619 gc time: 0
cpu time: 625 real time: 620 gc time: 0


with GC on:

cpu time: 422 real time: 431 gc time: 265
cpu time: 422 real time: 439 gc time: 221
cpu time: 437 real time: 431 gc time: 328
cpu time: 438 real time: 447 gc time: 360

Here's the program. I believe the difference is because the GC being
on keeps the data in the same block of memory over and over and thus
caching is more effective (and makes the GC's work itself cheaper than
it might otherwise be).

#lang racket/base
(define x #f)
(time
 (let loop ([n 10000000])
   (unless (zero? n)
     (set! x (cons 1 2))
     (loop (- n 1)))))

I wonder if the difference can be made even larger...?

Robby


Posted on the users mailing list.