cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
dnolen 2021-05-12T13:41:36.111500Z

wip for a generic and/or optimization pass - https://github.com/clojure/clojurescript/compare/opt-if

dnolen 2021-05-12T13:41:56.112Z

should hopefully fix the long outstanding core.async bugs

1
1
dnolen 2021-05-12T13:42:15.112400Z

one interesting result is this is fully generic and does not rely on form tagging

dnolen 2021-05-12T13:42:42.112900Z

it will just try to optimize any trivial let/test/if combo

dnolen 2021-05-12T13:43:08.113500Z

so actually it optimizes far more than the macro since, even if the first part of a thing can't be optimized, it can optimize the rest

dnolen 2021-05-12T13:43:28.113900Z

i.e. (and some.ns/x true false)

dnolen 2021-05-12T13:44:46.114700Z

this and fixing handling of #js literals would fix up the two big CLJS core.async pitfalls

dnolen 2021-05-12T13:49:37.115400Z

I had stalled a bit on this previously because I thought type inference was needed

dnolen 2021-05-12T13:49:45.115700Z

but now it's clear that this pass just runs after type inference

dpsutton 2021-05-12T14:30:23.116300Z

quick check in the repl and this fixes both https://clojure.atlassian.net/browse/ASYNC-91 and https://clojure.atlassian.net/browse/ASYNC-158

dnolen 2021-05-12T14:35:08.116800Z

@dpsutton nice - still working through the test cases

dpsutton 2021-05-12T14:35:23.117100Z

i'm interested to see what you do for that

dnolen 2021-05-12T14:35:44.117500Z

just a bunch of annoying variations but we should have explicit tests

dnolen 2021-05-12T14:35:52.117800Z

I want to turn this on and know it's more or less going to work

dpsutton 2021-05-12T14:36:39.118100Z

here are the two repros from those issues if you want them handy

dnolen 2021-05-12T14:49:50.118900Z

@dpsutton yeah I'm not so worried about the core.async tests

dnolen 2021-05-12T14:50:01.119300Z

just removing the and/or macro stuff makes the problem go away of course

dnolen 2021-05-12T14:50:18.119900Z

the tests I'm writing now are about checking that all desirable scenarios do optimize

dnolen 2021-05-12T14:51:26.120400Z

the and/or optimizations are on the critical path

dnolen 2021-05-12T14:52:31.120800Z

it's probably not obvious why, but it's one of the most important optimizations we do

dnolen 2021-05-12T14:53:25.121400Z

a quick summary is that and/or produce let

dnolen 2021-05-12T14:53:39.121800Z

but let can go anywhere in the emitted code, so it's wrapped in an IIFE

dnolen 2021-05-12T14:53:44.122Z

but that is a performance destroyer

dnolen 2021-05-12T14:54:13.122500Z

compound boolean expressions are in the persistent data structure code

dnolen 2021-05-12T14:54:25.122800Z

this stuff can never include an IIFE

dnolen 2021-05-12T14:54:28.123Z

nor a truth test

dpsutton 2021-05-12T15:00:56.123500Z

oh i knew that optimization was important but didn't think about it being used in the core data structures

dnolen 2021-05-12T15:05:04.123700Z

probably the single most important automatic optimization for that code

dnolen 2021-05-12T15:05:49.124200Z

otherwise would have to write really strange ClojureScript

dpsutton 2021-05-12T15:06:32.124600Z

yeah makes sense. just hadn't considered that.

dnolen 2021-05-12T19:34:37.125200Z

eye balling the persistent data structure code looks good

dnolen 2021-05-12T19:35:23.125800Z

no detectable regression in compiler performance at least from compiling all of the runtime tests

dnolen 2021-05-12T20:18:44.127200Z

would be nice to give master a try on your projects if you have a chance

kommen 2021-05-12T20:24:47.127600Z

sure, anything in particular we should pay attention to?

kommen 2021-05-12T20:57:39.128300Z

also no detectable compiler performance change for our production build

kommen 2021-05-12T21:04:01.130300Z

and nothing apparent wrong at runtime either after just a bit of testing

raspasov 2021-05-12T21:06:37.132200Z

Just bumped up to https://github.com/clojure/clojurescript/commit/927f221f8fc26a49db7d0dcfd1d70008a986fd8f . I get this error when compiling during dev: [Wed May 12 2021 13:54:01.150]  ERROR   [TypeError: logger_SINGLEQUOTE_.setLevel is not a function. (In ‘logger_SINGLEQUOTE_.setLevel(lvl)’, ‘logger_SINGLEQUOTE_.setLevel’ is undefined)] … but I have a feeling that’t not part of ClojureScript per-se. I have a hard time isolating where it’s coming from at the moment. The stacktrace does not look very helpful.

raspasov 2021-05-12T21:07:14.132600Z

Going to try compiling & running under :advanced

kommen 2021-05-12T21:09:21.133800Z

@raspasov from which version did you bump? this sounds more like one of the breaking changes from the .844 release: https://clojurescript.org/news/2021-04-06-release#_noteworthy_breaking_changes

raspasov 2021-05-12T21:09:47.134400Z

From the latest (I’m aware of those)

raspasov 2021-05-12T21:09:57.134600Z

From 1.10.844

kommen 2021-05-12T21:10:25.135100Z

ok, then sorry for my noise

raspasov 2021-05-12T21:10:33.135300Z

No problem.

raspasov 2021-05-12T21:10:33.135500Z

:advanced seems fine. Perhaps something in figwheel-main during :dev. Gotta investigate more.

raspasov 2021-05-12T22:31:59.136100Z

Yes, it’s from figwheel-main

dnolen 2021-05-12T22:42:20.136700Z

@raspasov were you on 844 before

dnolen 2021-05-12T22:43:52.137400Z

Oh sorry see the backlog - seems odd though there were some other changes

dnolen 2021-05-12T22:47:51.137800Z

For the and/or change no news is the best news

dnolen 2021-05-12T22:49:18.139Z

I guess and/or change could cause runtime improvements but probably only in lower level code

raspasov 2021-05-12T22:54:02.139600Z

I believe it’s coming from this line: https://github.com/bhauman/figwheel-repl/blob/master/src/figwheel/repl/logging.cljs#L63

raspasov 2021-05-12T22:56:19.141100Z

I’m guessing (could be wrong) because there’s an if statement that depends on the clojurescript-version it might not be selecting the proper logger since it’s a :sha version? https://github.com/bhauman/figwheel-repl/blob/master/src/figwheel/repl/logging.cljs#L19

raspasov 2021-05-12T22:56:46.141600Z

But this is a figwheel issue; As far as I can tell, the ClojureScript changes are fine.