meander icon indicating copy to clipboard operation
meander copied to clipboard

Epsilon is not compatible with Babashka

Open noprompt opened this issue 4 years ago • 10 comments

  • [x] Unable to resolve classname: clojure.lang.ILookup [at /private/tmp/meander/src/meander/substitute/syntax/epsilon.cljc:1441:24]

  • [x] user=> (require '[meander.epsilon] :reload) Could not resolve symbol: S__23485 [at /private/tmp/meander/src/meander/epsilon.clj]

Probably related to one of the (let [save-id (gensym* "S__")] constructs.

noprompt avatar Nov 18 '20 21:11 noprompt

It's pretty interesting how far we've come, but I'm not sure if meander in its current form is a good fit for babashka.

E.g.

  • The avoidance of predicates really works against performance in babashka: the clojure core predicates are pre-compiled with GraalVM in babashka, but the instance checks meander is doing are going through the interpreter.

  • Meander is trying to do a lot of optimizations (I think?) at load time via macros, which is causing slow startup time in babashka. The less code babashka has to process, the faster the program will be. Babashka doesn't have AOT of any kind: all source is going to be interpreted all over again on every command line invocation.

So shorter programs which rely on clojure.core instead of lower level interfaces will be faster in babashka. This is why e.g. https://github.com/xapix-io/matchete is pretty fast in babashka, but probably less performant in Clojure on the JVM than meander.

borkdude avatar Nov 19 '20 09:11 borkdude

The avoidance of predicates

It's not clear to me what you're referencing here. Can you provide some more detail?

Meander is trying to do a lot of optimizations (I think?) at load time via macros

This is true, however, we can avoid that by providing and suggesting the utilization of an interpreter namespace which works basically as matchete does. At the moment I'm fast tracking this by ripping out the use of the macro match.

noprompt avatar Nov 19 '20 17:11 noprompt

That would be interesting!

The part about the predicates: e.g. doing #(instance? clojure.lang.Seqable %) instead of seqable?. We discussed that perf optimisation yesterday on Slack.

borkdude avatar Nov 19 '20 17:11 borkdude

I now measured some differences and in babashka it's basically equally fast, so you can disregard that comment or at least take this as information that this won't help much in babashka, probably.

So the main issue is keeping the amount of code to load for meander as small as possible to get the best startup time possible.

borkdude avatar Nov 19 '20 17:11 borkdude

So the main issue is keeping the amount of code to load for meander as small as possible to get the best startup time possible.

I'm in!

noprompt avatar Nov 19 '20 17:11 noprompt

Is meander still not compatible with babashka?

aleksandersumowski avatar May 24 '22 15:05 aleksandersumowski

@aleksandersumowski Since the latest release you should be able to load meander, but I think there are a few edge cases that might not be working yet. Feel free to report them in terms of small standalone issues on the bb side of things and we can see if we can fix those.

borkdude avatar May 24 '22 15:05 borkdude

ok, I'll give it a try :)

aleksandersumowski avatar May 24 '22 16:05 aleksandersumowski

Some time has passed; and meander spurts a "babashka compatible" thing now in its README -- is this resolved? 😅

srenatus avatar Nov 02 '23 10:11 srenatus

yes, tests work with babashka on CI: https://github.com/noprompt/meander/actions/runs/5231806454/job/14159967827

borkdude avatar Nov 02 '23 10:11 borkdude