![]() Some expressions are omittable only when the arguments have certain types. In this case the application is marked with APPN_FLAG_OMITTABLE instead of relaying on the flags of the primitive. The optimizer can't use this flag to move the expression inside a lamba or across a potential continuation capture, unlike other omittable expressions. They can be moved only in more restricted conditions. For example, in this program #lang racket/base (define n 10000) (define m 10000) (time (define xs (build-list n (lambda (x) 0))) (length xs) (define ws (list->vector xs)) ; <-- omittable (for ([i (in-range m)]) (vector-ref ws 0))) ; <-- ws is used once If the optimizer moves the expression in the definition of ws inside the recursive lambda that is created by the for, then the code is equivalent to: #lang racket/base (define n 10000) (define m 10000) (time (define xs (build-list n (lambda (x) 0))) (length xs) (for ([i (in-range m)]) (vector-ref (list->vector xs) 0))) ; <-- moved here And the new code is O(n*m) instead of O(n+m). This example is a minimized version of the function kde from the plot package, where n=m and the bug changed the run time from linear to quadratic. |
||
---|---|---|
.. | ||
mzlib | ||
tests/racket | ||
info.rkt | ||
LICENSE.txt |