Opened 4 weeks ago

Closed 2 days ago

#1852 closed defect (fixed)

csc is absurdly inefficient when compiling large procedure calls

Reported by: zaifir Owned by:
Priority: major Milestone: 6.0.0
Component: compiler Version: 5.4.0
Keywords: Cc:
Estimated difficulty:

Description

Try compiling the following trivial module with CHICKEN 5:

(module foo *
  (import (scheme))
  (define bar
    (list (make-string 0)
          (make-string 1)
          ;; ...
          (make-string 4999)))
  )

That's an invocation of list to 5000 make-string invocations. On my system, this generates a > 15 MB C source file, which takes at least 10 minutes to compile (I gave up & sent a SIGTERM).

Replacing the list with a 5000-element vector & then converting to a list, e.g.

  (define bar
    (let ((vec (make-vector 5000)))
      (vector-set! vec 0 (make-string 0))
      ;; ...
      (vector-set! vec 4999 (make-string 4999))
      (vector->list vec)))

results in fairly normal compilation times. But this is a very ugly workaround when your intention is to compile a procedure call with a large number of arguments.

Change History (2)

comment:1 Changed 4 weeks ago by zaifir

I should add that this bug seems only to affect calls with many procedure-call subexpressions. (list 0 1 ... 10000) compiles normally, but (list (make-string 0) ... (make-string 10000)) does not.

comment:2 Changed 2 days ago by sjamaan

Milestone: someday6.0.0
Resolution: fixed
Status: newclosed

This has been addressed in master (upcoming CHICKEN 6), with 0d6ab712 (to make the generated C manageable) and c9bd0116 (to reduce Scheme->translation times to normal)

Note: See TracTickets for help on using tickets.