Skip to content

Instantly share code, notes, and snippets.

Staying home

Sam Tobin-Hochstadt samth

Staying home
View GitHub Profile
View lex.rkt
#lang racket
(require sugar)
(define (go file h)
(define lines (file->lines file))
(match-define (list header chunks ... summary) (filter-split lines (lambda (l) (equal? l ""))))
(define p
(for/list ([l chunks])
(define size (regexp-match "leak of (.+) .* in (.+) object" (car l)))
(list (and size (map string->number (cdr size)))
(filter values
View mult2.rkt
#lang racket
(require racket/fixnum)
(define (bignum? x) (integer? x))
(define ($bignum-length x) (quotient (integer-length x) 10))
(define (integer* x y) (* x y))
(require racket/trace)
(define-syntax-rule (assert b . args)
View pkg-failures.txt
#hash((missing-unstable . ("pict3d-orig"))
((#f missing-module) . ("satore"))
View countwords.rkt
#lang racket/base
(require racket/fixnum racket/unsafe/ops racket/vector)
(#%declare #:unsafe)
(define basis 2166136261)
(define prime 16777619)
(define (fnv1a bs scale)
(for/fold ([h basis])
([b (in-bytes bs)])
View count.rkt
#lang racket/base
(require racket/string racket/bytes racket/vector racket/port)
(define h (make-hash))
;(#%declare #:unsafe)
(define (split-lines/bytes)
(for* ([l (in-bytes-lines)])
(let loop ([i 0] [last 0])
(cond [(= i (bytes-length l))
View count.rkt
#lang racket/base
(require racket/string racket/bytes racket/vector racket/port)
(define h (make-hash))
(#%declare #:unsafe)
(define (split-lines)
(for* ([l (in-bytes-lines)])
(let loop ([i 0] [last 0])
(cond [(= i (bytes-length l))
View missing.txt
631 [warning] Implementation of identifier unsafe-undefined not found in module #%unsafe!
544 [warning] Implementation of identifier #%variable-reference not found in module #%core!
544 [warning] Implementation of identifier variable-reference-from-unsafe? not found in module #%linklet-primitive!
109 [warning] Implementation of identifier fx+ not found in module #%flfxnum!
88 [warning] Implementation of identifier prop:authentic not found in module #%runtime!
80 [warning] Implementation of identifier primitive-table not found in module #%linklet-primitive!
73 [warning] Implementation of identifier unsafe-place-local-ref not found in module #%unsafe!
40 [warning] Implementation of identifier unsafe-place-local-set! not found in module #%unsafe!
39 [warning] Implementation of identifier vector*-ref not found in module #%runtime!
38 [warning] Implementation of identifier eof-object? not found in module #%runtime!
View expander.rktl
This file has been truncated, but you can view the full file.
;; This is not the original source code. Instead, this is the code after
;; fully expanding and flattening into a single linklet.
(module expander '#%kernel
(#%require '#%paramz '#%unsafe '#%flfxnum '#%linklet '#%extfl)
(rename boot boot)
(rename 1/bound-identifier=? bound-identifier=?)
(rename 1/compile compile)
(rename compile-keep-source-locations! compile-keep-source-locations!)
samth /
Last active Feb 25, 2021
Racket performance improvement over 17 years

Arseny Kapoulkine (h/t John Regehr) wrote a nice exploration of how LLVM from 2010 compares to the performance we get today. I decided to try out an old version of Racket, and compare performance to a modern version.

The versions I compared were:

  • MzScheme 206p1, released January 2004
  • Racket, compiled February 2021 (using the Chez Scheme backend)

I measured exactly one benchmark, a mandelbrot set computation from the Computer Language Benchmarks Game, using the implementation in the Racket repository. Of course, that code won't run on v206p1, so I modified it to avoid new features of Racket. The modified version is below.

Of course, many of the features that have been added make the program faster, so it's important to compare with the performance of the modern code. There's even a [parallel version](https://githu

View utils.rkt
#lang at-exp racket
(provide indented
campuswire-url campuswire campuswire-invite ; piazza-url piazza
zoom canvas
youtube watch-youtube
first-day-of-break-week week