Summary
csc is absurdly inefficient when compiling large procedure calls
Metadata
- Id: 159106f838717ee7fb2324311b5b30f9c740430c
- Trac id: 1852
- Type: defect
- Reporter: zaifir
- Owner:
- Cc:
- Status: closed
- Component: compiler
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: 6.0.0
- Version: 5.4.0
- Changetime: 2025-07-29 10:55:29 UTC
- Created: 2025-07-01 19:21:03 UTC
- Keywords:
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.
Changes and comments
[2025-07-01 20:16:40 UTC] zaifir wrote:
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.
[2025-07-29 10:55:29 UTC] sjamaan changed status from new to closed
[2025-07-29 10:55:29 UTC] sjamaan set resolution to fixed
[2025-07-29 10:55:29 UTC] sjamaan changed milestone from someday to 6.0.0
[2025-07-29 10:55:29 UTC] sjamaan wrote:
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)