Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closure analyzer output: let #470

Closed
borkdude opened this issue Dec 16, 2020 · 0 comments
Closed

Closure analyzer output: let #470

borkdude opened this issue Dec 16, 2020 · 0 comments

Comments

@borkdude
Copy link
Collaborator

The following script demonstrates that returning a closure directly from the analyzer can have beneficial effect on performance:

;; run with:
;; clojure -J-Dclojure.compiler.direct-linking=true -M let_closure.clj
;; master: "Elapsed time: 6990.686673 msecs"
;; let-closure: "Elapsed time: 5351.171676 msecs"

(require '[sci.core :as sci])

(def ctx (sci/init {}))

(require '[sci.impl.analyzer :as ana])

(def analyzed (ana/analyze ctx '(let [x 1] x)))

(require '[sci.impl.evaluator :as eval])

(prn (eval/eval ctx analyzed))

(time (dotimes [_ 10000000]
        (eval/eval ctx analyzed)))

I didn't see a regression in the binary loop example:

$ time tmp/let-closure "(loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val))"
1000000
tmp/let-closure    1.45s  user 0.09s system 99% cpu 1.544 total

(but unfortunately also no speedup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant