Fork me on GitHub
#clojure-dev
<
2019-06-09
>
dominicm10:06:37

Given that core.async takes ~4s to require, is it worthwhile providing a aot'd version of that dependency for the purposes of speeding up programs relying on it? Any downsides to that? Yada uses core.async, and it's making yada look very slow as this is one of the biggest causes of slowdown. @alexmiller I think you mentioned you were working on a potential caching utility for an upcoming clojure, would the need for this be obsoleted by your work?

borkdude12:06:38

@dominicm maybe you can lazily require core.async, or is core.async also used by manifold and a non-optional thing in yada?

dominicm12:06:01

Manifold uses core async too, and I don't think yada can be lazy because it's protocol extension (although maybe it could try and extend it only when required? Sounds potentially dodgy)

dominicm12:06:43

having gone deeper now, it looks like it's the core.async.impl.ioc-macro's dependency of tools.analyzer which is slow.

Alex Miller (Clojure team)12:06:04

Providing only an aot core.async is a recipe for trouble. You really need to aot all dependent code as well to avoid the classic protocol reloading issues. So would also need tools.analyzer etc. it’s really best to aot at the app level where you can do everything (and where you’re not deploying to maven and making that choice for everyone else)

Alex Miller (Clojure team)12:06:22

And yes, I would expect the caching work would help. Really any time you’re reading and compiling something into a class that you’ve done before, it would potentially help

👍 4
borkdude20:06:16

user=> (defrecord ^:private Foo [a])
user.Foo
user=> (meta #'->Foo)
{:arglists ([a]), :doc "Positional factory function for class user.Foo.", :line 1, :column 1, :file "NO_SOURCE_PATH", :name ->Foo, :ns #object[clojure.lang.Namespace 0x64b70919 "user"]}

Alex Miller (Clojure team)21:06:59

Private records are not a thing

gfredericks21:06:55

but I'd wager you could alter-meta! the factory functions to be private

Alex Miller (Clojure team)21:06:43

You can, or ns-unmap to remove entirely (which we do in a couple places)

gfredericks21:06:12

I guess at the end of the file, if you want the references therein to compile

dominicm21:06:03

Any reason they're not a thing?

mikerod21:06:29

@dominicm seems like that’d be confusing. Can’t have a “private top level” java class. So would have to be like package private. Which clj doesn’t really utilize. Only the auto generated factory functions would make any sense, and that seems odd to me.

borkdude22:06:03

just for the record, CLJS:

ClojureScript 1.10.520
cljs.user=> (defrecord ^:private Foo [a])
cljs.user/Foo
cljs.user=> (meta #'->Foo)
{:private true, :ns cljs.user, :name ->Foo, :file nil, :end-column 25, :column 1, :internal-ctor true, :factory :positional, :line 1, :end-line 1, :arglists ([a]), :doc "Positional factory function for cljs.user/Foo.", :test nil}

borkdude22:06:12

this is used in CLJS source code