Fork me on GitHub
#vim
<
2017-07-24
>
dominicm19:07:05

> However, I have found that, if I AOT compile all of zprint and the associated libraries (and use just minimal libraries), and use the right Java command line arguments (and caching techniques), that I can get a Clojure zprint filter to startup slightly faster than a Clojurescript zprint filter. And to do so in just under 1 second. Which isn't zero, but which is fast enough to be perfectly useful. > Moreover, as the amount of source to be formatted grows, the Clojure version runs considerably faster than the Clojurescript version. This seriously puts clojure on the tooling train again.

jebberjeb19:07:09

wow, start a java process and load clojure runtime in under a second?!

jebberjeb20:07:12

tell me more!

dominicm20:07:21

I have no more yet :( gotta benchmark it and test. But it makes a very compelling alternative to something like Julia or Go.

dominicm20:07:43

I'm considering hooking up clojure-neovim and AOT compiling it to check it starts fast, same for tools.nrepl.

jebberjeb20:07:07

That'd be nice to see.

dominicm20:07:31

@jebberjeb do you release neovim-client to a repo?

dominicm20:07:36

clojure.lang.ExceptionInfo: Could not find artifact neovim-client:neovim-client:jar:0.1.0 in clojars ()

jebberjeb20:07:23

@dominicm I don't think I ever did, no.

jebberjeb20:07:33

I can though.

jebberjeb20:07:38

alright, let me just knock this out real quick

dominicm20:07:25

thanks ❤️

dominicm20:07:44

and the REPL is awaaay

jebberjeb20:07:35

Now you too can mutate neovim from your REPL! Why you would want to is another issue 🙂

jebberjeb20:07:59

My thinking is that any piece of software isn't ever really complete without a REPL to modify it at runtime.

dominicm20:07:57

You've been hanging round Stu I see 😉

dominicm20:07:26

https://github.com/clojure-vim/neovim-client/blob/master/project.clj you're bringing in an old core.async version which doesn't work with latest specs 😞

mikepjb20:07:46

it can be run on 1.9.3 etc

mikepjb20:07:15

then invoke the script like so command! Load :!hurl "(load-file \"%:p\")"

dominicm21:07:08

that appcds script is pretty intense

jebberjeb21:07:46

@dominicm 0.1.1 on clojars w/ new core.async version

dominicm21:07:04

thanks! You're on it today. I had worked around it, thanks a bunch 🙂

dominicm21:07:56

Hmm, I have 5s. Not terrible. But not great.

dominicm21:07:40

gonna have a play, I might have a few alterations

dominicm21:07:47

I think there's clj files where there shouldn't be

jebberjeb21:07:05

you mean generated stuff?

dominicm21:07:14

uh, does neovim-client generate namespaces dynamically?

dominicm21:07:58

0.6s when stripping clj files & not bringing in neovim-client (just tools.nrepl)

jebberjeb21:07:18

It doesn't generate anything at runtime

dominicm21:07:50

& I'm using the slightly slower hack of the two

dominicm21:07:16

I should seriously try feed this into that javascript java interpreter whilst I'm at it

jebberjeb21:07:45

Could be one of neovim-client's other deps slowing things down?

dominicm21:07:39

I lied, I used java -jar before, which was 0.6, with the slower hack it's 0.3s

dominicm21:07:53

@jebberjeb I can't actually get it to compile as is.

jebberjeb21:07:35

You mean, you can't compile neovim-client?

dominicm21:07:55

It compiles, but doesn't run if I strip out all the clj files

dominicm21:07:09

(meaning it can't find the class)

jebberjeb21:07:12

yeah all the generating is still being done statically

jebberjeb21:07:22

oh oh I see what you're saying

jebberjeb21:07:34

gotcha, I think

dominicm21:07:35

Caused by: java.io.FileNotFoundException: Could not locate neovim_client/nvim__init.class or neovim_client/nvim.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

dominicm21:07:14

I'm gonna mark it as an entry point to aot, see if that fixes it

dominicm21:07:25

Yeah, leiningen does a terrible job of AOT. Boot did a better job, but I couldn't get neovim-client to aot though.

dominicm21:07:05

I think AOT has a bad reputation, and something tells me it's not working properly.

jebberjeb21:07:11

Hmm, I thought I'd tried it -- but I was never really sure it worked.

jebberjeb21:07:28

AOT's not universally loved, no

dominicm22:07:44

ah, apparently gotta get this uberjar-exclusions [#"\.(clj|java|cljs)"]

jebberjeb22:07:31

that strips them all out?

dominicm22:07:59

yep. Which speeds up the just nrepl build, but is now failing the neovim build again

dominicm22:07:38

okay, gonna go fully circular, and add every namespace I can see used.

dominicm22:07:13

Finally got them all ironed out. 0.8s

dominicm22:07:20

with neovim client

dominicm22:07:35

0.8s, is that quick enough startup? :thinking_face:

dominicm23:07:49

@jebberjeb

Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.etsy.net.UnixDomainSocket.getJarPath(Unknown Source)
	at com.etsy.net.UnixDomainSocket.<clinit>(Unknown Source)
	at neovim_client.nvim$new.invokeStatic(nvim.clj:51)
	at neovim_client.nvim$new.invoke(nvim.clj:51)
	at io.dominic.test2bencode$_main.invokeStatic(test2bencode.clj:12)
	at io.dominic.test2bencode$_main.doInvoke(test2bencode.clj:7)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at io.dominic.test2bencode.main(Unknown Source)
Caused by: java.lang.NullPointerException
	at com.etsy.net.JUDS.<clinit>(Unknown Source)
	... 8 more
Getting this with unix sockets, I notice they're recent-ish. Do you know if they work for others & I'm being daft or..?

dominicm23:07:15

hmm, works outside of uberjar. That "getJarPath" looks suspicious.

dominicm23:07:26

I'm guessing it doesn't work inside an uberjar because reasons. That's very unfortunate. 😞

dominicm23:07:46

Either way, this is very fast & very interesting.

dominicm23:07:22

(ns io.dominic.test2bencode
  (:require [neovim-client.0.api :as nvim.api]
            [neovim-client.nvim :as nvim]
            [clojure.tools.nrepl :as repl])
  (:gen-class))

(defn -main
  "I don't do a whole lot ... yet."
  [& [socket]]
  (println "Hello, World!")
  (let [client (nvim/new 0 "localhost" 7777)]
    (nvim.api/call-function client "Foo"
                            [(with-open [conn (repl/connect :port 38517)]
                               (-> (repl/client conn 1000)
                                   (repl/message {:op "eval" :code "(+ 2 3)"})
                                   repl/response-values))])
    (System/exit 0)))
Runs in 1.8s ^^ I would ofc be making this into a long-running process. But very awesome regardless.

dominicm23:07:03

Thanks for your great library @jebberjeb