dyoo / whalesong

Whalesong: Racket to JavaScript compiler
http://hashcollision.org/whalesong
250 stars 30 forks source link

computation appears to be disappearing #77

Closed dyoo closed 12 years ago

dyoo commented 12 years ago

When I try running the following program, Chrome appears to just stop computing after a while. This is bad. I need to find out what's going on.

#lang planet dyoo/whalesong

(define (mylen x)
  (cond
    [(empty? x)
     0]
    [else
     (add1 (mylen (rest x)))]))
"computing length"
(define v (build-list 1000000 (lambda (i) i)))
(printf "Built list\n")
(mylen v)
"done computing length"
dyoo commented 12 years ago

When translated to tail-recursive form, the computation succeeds, so something strange is happening. Maybe the browser is killing us?

dyoo commented 12 years ago

Investigated partially. It seems to do with some internals of the Chrome browser. After a certain point, the browser appears to go crazy with allocation and then it just stops. It's very strange. At a certain point, it looks like it's computing some long-running computation, but it's not on the trampoline, and I have no idea what it's computing...

By the way, the code above stresses the size of the stack, arithmetic, and continuation marks. By eliminating the generic arithmetic and stack traces, the runtime of the program drops dramatically. This stresses the important of fixing the performance of the numeric tower on common operations like add1 & sub1.

dyoo commented 12 years ago

Closing bug for now; I don't think I can do anything actionable about this at the moment.