Is there anyway the process of registering annotations can be sped up? It takes a decent amount of time to the startup process of our application which already had a longish startup time lol.
I assume you're talking about dev-time? I think a lot of time is spent compiling the type checker. Perhaps see if this helps https://clojure.org/guides/dev_startup_time
oh I forgot you're using t/pred which forces all types to collect
so this is affecting your production startup? that's a problem.
do you deploy your app with AOT compiled sources?
It affects everything really. Whenever we run tests, start the site, type check, certain linters etc. Its not the worst thing but I was just curious if there is anyway to speed that up or remove it entirely. For our production setup it does do the same thing there but we have a rolling update setup so it doesn't cause our service to go down or anything for longer so its honestly more of a dev thing.
We use lein uberjar to compile the jar
Do you have this in your project.clj?
:profiles {:uberjar {:aot :all}}
that might improve prod startup a little bit
there's a bit more optimization I can do for collecting types
it's quite heavy right now to annotate a type
do you include the checker at production time or just the typed.clj.runtime?
Yeah that does remove it for the jar thanks.
We use [org.typedclojure/typed.clj.runtime "1.2.2-SNAPSHOT"], [org.typedclojure/typed.clj.checker "1.2.2-SNAPSHOT"], and [org.typedclojure/typed.lib.clojure "1.2.2-SNAPSHOT"]. I think we experimented previously and we needed those or it wouldn't work since we use t/pred
you should be able to use pred with just typed.clj.runtime and typed.lib.clojure
it's an oversight on my part if not
Ok let me try that
I will try a few ideas on the loading speedup and get back to you.
removing the checker should have no effect on the loading time but will drastically reduce the # of prod deps
Sounds good thanks. I was able to move the checker to dev dependencies and everything still works.
for production startup, AOT compilation may solve many of your issues. t/pred only loads annotation at macroexpansion time.
Yeah it cuts the startup time down significantly
Idk how i never heard of that before
It pre compiles all of the files that is what we want anyways I wonder why that isn't the default
great. is typed clojure loading anything after aot?
No it doesn't print out the registering annotations stuff
ok brilliant
Could you send me the list of annotations loaded during dev?
at least the namespaces owned by typed clojure
just need to make sure annotations for the checker's implementation aren't being loaded
In dev I get
Registering annotations from typed.ann.clojure...
Registering annotations from typed.cljc.runtime.env-utils-annotations...
Registering annotations from typed.clj.checker.assoc-utils...
Registering annotations from typed.clj.checker.parse-unparse...
Registering annotations from typed.clj.checker.subtype...
Registering annotations from typed.cljc.checker.check...
Registering annotations from typed.cljc.checker.check.funapp...
Registering annotations from typed.cljc.checker.cs-gen...
Registering annotations from typed.cljc.checker.filter-ops...
Registering annotations from typed.cljc.checker.filter-rep...
Registering annotations from typed.cljc.checker.lex-env...
Registering annotations from typed.cljc.checker.object-rep...
Registering annotations from typed.cljc.checker.var-env...hmm ok thanks
latest main now AOT compiles typed.clojure and clojure.core.typed. might give 100ms back during dev.
I'll go through and see what else I can AOT compile.
another improvement, you should only see this log now, all the others won't be loaded:
Registering annotations from typed.ann.clojure...
that should be a drastic improvement on startup since before t/pred would load half the checker in dev.
the tradeoff being the first t/check-ns-clj will take longer. but I'll work on that.
Thatโs awesome thanks. It does seem to be much faster now.
I think something in a recent snapshot commit is causing this weird error during our CI pipeline when doing lein uberjar. We are getting this error
Registering annotations from typed.ann.clojure...
Unexpected error macroexpanding tyc/pred at (ourfile.clj:43:12).
Unexpected error (IndexOutOfBoundsException) macroexpanding tyc/pred at (ourfile.clj:43:12).
Method code too large!
That line its referring to looks like (def user? (tyc/pred User)) and User is just a hmap defaliasthanks, reverting
https://github.com/typedclojure/typedclojure/commit/eb40954e383371c25865f550a7ae1b75b2915806
Cool thanks
I tried the optimization again, lmk if it broke anything. Compilation should be quicker and probably loading too.
well the build failed, will try later.
there's a flaky test that's worrying me but it's deploying now.