Fork me on GitHub
#sci2020-06-25
>
Kevin10:06:22

By the way, I remember reading something in the Malli channel about trimming the sci build size for CLJS?

Kevin10:06:30

I don't think it's in the chat anymore though

borkdude10:06:51

I think @ikitommi had ideas about this.

Kevin10:06:09

SCI is about half my entire build at the moment haha

borkdude10:06:59

One reason is that it adds lots of docstrings you might not need. Another reason is that it holds on to functions you might not need. But that's hard to predict in an interpreter, since you don't know what users want to use

Kevin10:06:36

Interesting. The second one makes sense. In my case everything read by SCI is located in EDN file(s)

borkdude10:06:06

But sci doesn't know before-hand what's in your EDN files

borkdude10:06:47

I'm open to ideas of making a more minimal build through some API. The only condition I have is that it should not affect performance of GraalVM binaries like babashka

Kevin10:06:52

I think it would make sense to have some kind of optional build size optimization, which is off by default

Kevin10:06:12

So that no one is affected, unless they opt-in knowing what they're doing

borkdude10:06:55

I think the idea that ikitommi has is more fine-grained. The namespaces.cljc file contains top-level datastructures with all the core namespaces in it. Those should be lifted into a function and then users can do a select-keys or dissoc on those namespaces, and making a top-level value out of that. That should help.

Kevin10:06:17

core namespaces being the namespaces available in SCI?

borkdude10:06:17

I've thought about a default setting, but I can't think of a scenario where there's only one default setting that fits all

borkdude10:06:26

yes, clojure.core, clojure.string, etc

Kevin10:06:33

Checked out the namespaces.cljc file, and I get what you mean now

Kevin10:06:51

Basically if you remove a NS / function from there, that would be it?

Kevin10:06:19

Well not literally remove, but just filter out

borkdude10:06:17

yes, but that should be an option to the user. e.g.:

(sci.core/add-namespace opts 'clojure.core {:exclude [...]}) or `:include
` something like that

Kevin10:06:32

Yeah of course

Kevin10:06:58

I wonder if it would work if I took all my EDN files, get all symbols, and just :include all of that. I assume it wouldn't since those symbol might have dependencies not listed in there?

borkdude10:06:11

yep, could very well be.

borkdude10:06:39

if x depends on y and you're not including y, you're doomed

borkdude10:06:19

but with some testing it should be doable to figure it out

borkdude10:06:43

btw, the build is still a lot smaller than when you go with self-hosted CLJS which is 8 megabytes or so

Kevin10:06:20

Hey I'm not complaining 😛

Kevin10:06:03

I'm able to do some amazing things with Sci, which is great

borkdude10:06:19

would be great if we could reduce the build some more. <hammock time/>

ikitommi11:06:28

hi. just prepared malli for dce, users can cut out schemas, from def to defn and one top-level def that can be customized to have the default (all schmas) or an empty registry, which can be customly collected

ikitommi11:06:06

select-keys won’t work here, as Closure tracks down things statically, if you call the function that has everything, everything is added.

ikitommi11:06:38

but, one can create a new map manually, having just the needed key->value mappings and only those will be in.

borkdude11:06:22

what about compile/macro time select-keys?

3
ikitommi11:06:22

I think there are two options here. For both: make all the def defns and split them into smaller parts, e.g. clojure-set-bindings, clojure-walk-bindingsetc. Then, the options:

ikitommi11:06:53

could work.

ikitommi11:06:01

but the options :): 1. have a global def collecting all int sci.core and create a new entrypoint, like sci.custom that doesn’t have the def, but an api that requires the bindings as parameter 2. have a compiler switch (`:closure-defines` / :jvm-opts) which allow to empty the default registry 3. macro-time select-keys, might work, tested something like this, coudn’t get it to work

ikitommi11:06:21

I think 1 would be relatively easy

borkdude11:06:32

I also like 1. Could you post this into the issue?

ikitommi11:06:53

did.

❤️ 3
ikitommi11:06:16

didn’t test the syntax, buf something like:

(require '[sci.custom])
(require '[sci.namepaces :as n])
(require '[clojure.walk :as walk])

(def sci-eval 
  (sci.custom/evaluator 
    {:bindings (merge (n/cloure-core-bindings) 
                      (n/clojure-set-bindings) 
                      {'walk (n/copy-var clojure.walk/walk...)})})

(sci-eval "(int? 1)")
; => true

ikitommi11:06:08

also, options not to include docstring via options would be great, would allow tiny sci runtimes.

borkdude11:06:55

When I added the docstrings, the bundle grew with 200kb. I recently experimented with a closure defines to exclude them but it only mattered 8kb or so. Don't know what's up, needs more attention...

👀 3
ikitommi12:06:06

did the size decrease in clojure.core? Not sure how those are reported.

borkdude12:06:11

I just looked at the total size of sci.min.js overall

ikitommi11:06:16

There is a one clojure-based startup in Finland, running clojure in blockchain (real estate smart contracts), poked them to use sci instead.