Fork me on GitHub
#missionary
<
2022-07-25
>
reedho03:07:31

(time
  (let [n 10000000] ;; 10M
    (m/? (m/reduce {}
                   nil
                   (m/ap (loop [[x & xs] (range n)]
                           (if xs
                             (m/amb> x (recur xs))
                             (m/amb> x))
                           ))))))
"Elapsed time: 9328.258661 msecs"
9999999
Above code run ok as expected. Higher value of n, e.g. doubling it by 2x will result in OutOfMemoryError. Increasing the JVM memory (e.g. -Xmx2g) will likely just make the OOM error to be thrown longer. More memory will result the jvm hang: OpenJDK 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGINT to handler- the VM may need to be forcibly terminated

leonoel17:07:06

it is a known issue and will be solved in b.27, this loop can be run in constant space indeed

leonoel17:07:21

BTW you can try b.27-SNAPSHOT I just tested with 500M and it works fine with default settings

reedho23:07:34

Great, thanks. ❤️💯