Fork me on GitHub
#clojure-dev
<
2022-12-14
>
mfikes03:12:40

I wonder if the perf of expressions like this are impacted by the IDrop stuff

(take 3 (filter even? (range 100000000)))

mfikes04:12:24

(count (chunk-first (range 100000000))) is 100000000

mfikes05:12:11

In 1.11.1 this would be 32 and laziness would be preserved... while the change seems to make that expression be eager

Alex Miller (Clojure team)13:12:12

Range never actually eagerly computed values, so nothing has changed there - it just makes one giant chunk rather than n

Alex Miller (Clojure team)13:12:36

I did perf test the range changes in a variety of ways and it is much faster in some cases, like reduce and iteration (a wash in others)

Alex Miller (Clojure team)13:12:27

filter is still making a chunk of 32

mfikes13:12:37

Ahh, perhaps this isn't the case on Clojure master? If I evaluate (take 3 (filter even? (range 100000000))) in 1.12.1-alpha1, I think I get a huge chunk being evaluated...

mfikes13:12:04

Here is a repro... if you evaluate (take 3 (filter (fn [x] (prn x) (even? x)) (range 100))) you will see 100 applications

Alex Miller (Clojure team)13:12:14

I’ll take a look

👍 1
mfikes13:12:45

Extracting a bit of the logic from filter this seems relevant: (let [r (range 100)] [(chunked-seq? r) (count (chunk-first r))]) -> [true 100]

💯 1
Alex Miller (Clojure team)20:12:09

Rich and I talked about it today, I'm going to just fall back to making 32-element chunks in range for now, will target that at alpha2

😮 2
Alex Miller (Clojure team)20:12:15

thanks for the question!

👍 1
1