boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

17-gc-cons-churn.scm (597B)


      1 ;; Cons churn stress: allocate many short-lived pairs, force multiple
      2 ;; GC cycles. lisp.M1's bring-up heap is 32 KB (~2048 pairs). Each
      3 ;; user-level cons drives several pair allocations once eval_args and
      4 ;; the marshal path are counted, so 5000 iterations exhaust the arena
      5 ;; multiple times over and exercise mark + sweep + freelist reuse.
      6 ;;
      7 ;; Uses the explicit `(define name (lambda ...))` form because the
      8 ;; bring-up evaluator does not expand `(define (name args) body)`.
      9 
     10 (define churn
     11   (lambda (n)
     12     (if (= n 0)
     13         42
     14         (begin (cons n n) (churn (- n 1))))))
     15 
     16 (churn 5000)