core-typed

2024-06-24T15:36:19.042909Z

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.

2024-06-24T18:22:52.172109Z

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

2024-06-24T18:23:32.878899Z

oh I forgot you're using t/pred which forces all types to collect

2024-06-24T18:24:04.275239Z

so this is affecting your production startup? that's a problem.

2024-06-24T18:32:55.703789Z

do you deploy your app with AOT compiled sources?

2024-06-24T18:34:00.237729Z

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.

2024-06-24T18:35:40.949389Z

We use lein uberjar to compile the jar

2024-06-24T18:37:59.306679Z

Do you have this in your project.clj?

:profiles {:uberjar {:aot :all}}

2024-06-24T18:38:11.689699Z

that might improve prod startup a little bit

2024-06-24T18:40:19.843949Z

there's a bit more optimization I can do for collecting types

2024-06-24T18:40:40.456089Z

it's quite heavy right now to annotate a type

2024-06-24T18:41:35.860729Z

do you include the checker at production time or just the typed.clj.runtime?

2024-06-24T18:49:50.880309Z

Yeah that does remove it for the jar thanks.

2024-06-24T18:50:32.692359Z

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

2024-06-24T18:51:15.783409Z

you should be able to use pred with just typed.clj.runtime and typed.lib.clojure

2024-06-24T18:51:48.168969Z

it's an oversight on my part if not

2024-06-24T18:52:31.945739Z

Ok let me try that

2024-06-24T18:52:58.867879Z

I will try a few ideas on the loading speedup and get back to you.

2024-06-24T18:54:46.948359Z

removing the checker should have no effect on the loading time but will drastically reduce the # of prod deps

2024-06-24T19:02:45.680109Z

Sounds good thanks. I was able to move the checker to dev dependencies and everything still works.

๐Ÿ‘ 1
2024-06-24T19:09:52.358879Z

for production startup, AOT compilation may solve many of your issues. t/pred only loads annotation at macroexpansion time.

2024-06-24T19:10:16.351789Z

Yeah it cuts the startup time down significantly

2024-06-24T19:10:23.487469Z

Idk how i never heard of that before

2024-06-24T19:10:48.631229Z

It pre compiles all of the files that is what we want anyways I wonder why that isn't the default

2024-06-24T19:11:36.199529Z

great. is typed clojure loading anything after aot?

2024-06-24T19:11:53.764229Z

No it doesn't print out the registering annotations stuff

2024-06-24T19:12:02.543949Z

ok brilliant

2024-06-24T19:29:17.197079Z

Could you send me the list of annotations loaded during dev?

2024-06-24T19:29:46.651449Z

at least the namespaces owned by typed clojure

2024-06-24T19:32:03.546019Z

just need to make sure annotations for the checker's implementation aren't being loaded

2024-06-24T20:16:07.018929Z

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...

2024-06-24T20:17:05.405949Z

hmm ok thanks

2024-06-25T03:08:29.971309Z

latest main now AOT compiles typed.clojure and clojure.core.typed. might give 100ms back during dev.

2024-06-25T03:08:57.214849Z

I'll go through and see what else I can AOT compile.

2024-06-25T04:28:45.844739Z

another improvement, you should only see this log now, all the others won't be loaded:

Registering annotations from typed.ann.clojure...

2024-06-25T04:29:55.707199Z

that should be a drastic improvement on startup since before t/pred would load half the checker in dev.

2024-06-25T04:30:54.497169Z

the tradeoff being the first t/check-ns-clj will take longer. but I'll work on that.

2024-06-25T15:44:00.360109Z

Thatโ€™s awesome thanks. It does seem to be much faster now.

๐Ÿ‘ 1
2024-06-25T20:41:40.522389Z

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 defalias

2024-06-25T20:44:11.473809Z

thanks, reverting

2024-06-25T20:47:05.915389Z

Cool thanks

2024-06-25T23:51:32.463719Z

I tried the optimization again, lmk if it broke anything. Compilation should be quicker and probably loading too.

2024-06-25T23:54:08.167229Z

well the build failed, will try later.

2024-06-25T23:58:02.019869Z

there's a flaky test that's worrying me but it's deploying now.