Fork me on GitHub
#clojure-europe
<
2022-04-22
>
Eugen07:04:26

bună dimineața (good morning)

otfrom07:04:32

I'm wondering what it is the "coffee" and feeling sorry that it looks like Nescafe

otfrom07:04:53

ah, looks like an advert rather than a music video?

Eugen11:04:51

yes, advert 🙂 the song is quite nice actually - I listend to that lots of times

genRaiy08:04:51

Good morning for an al fresco breakfast

thomas08:04:22

TGIF!!!

🙏 2
slipset08:04:03

Morning from Iceland!

otfrom09:04:59

hmm... a load level of 32 is a bit higher than I want on a 16 core machine. Too much time in kernel

otfrom10:04:10

who would have thought removing a bit of arithmetic that was using reflection would lower your execution time from 12-15 minutes to under 3 minutes? (everyone, everyone would have thought that)

😂 9
Ben Sless20:04:54

Find out how you can SLICE your code's execution time with ONE SIMPLE TRICK

Ben Sless20:04:16

"I dont know man protocols are slow" uses satisfies? in prod

otfrom20:04:32

This just needed a bit of type hinting

borkdude21:04:19

@UK0810AQ2 In a next version of clj-kondo maybe satisfies? can be discouraged via configuration - perhaps you're interested in that? :) https://github.com/clj-kondo/clj-kondo/issues/996

genRaiy22:04:49

Does a namespace have Java interop? If so, is it subject to reflection warnings? That could be a nice linter action.

genRaiy15:04:45

I'm going to have reflection warnings on by default in replacement and have a place for them in data for the forms.

borkdude15:04:31

can you elaborate with an example / screenshot?

Ben Sless15:04:15

@U04V15CAJ I'm extreme but some of these should be on by default - read string, satisfies and flatten all signal something wrong

borkdude15:04:22

@UK0810AQ2 I agree but I want to start with an empty config, we can always add things over time

👍 1
genRaiy11:04:44

@U04V15CAJ - yes, eventually 🙂

otfrom11:04:00

Now I want to see more example kondo configs

plexus11:04:34

Anywhere where I can read about concerns over satisfies?

borkdude11:04:19

Probably it's mentioned in @U055NJ5CC’s talk on ClojureTRE called Naked Performance - also @UK0810AQ2 probably can point you to some resources.

Ben Sless11:04:34

@U07FP7QJ0 just read the implementation 😅 It'll make you sweat bullets, it does a lot You can also look here to see the effects https://bsless.github.io/datahike-datalog-parser/ Apologies for the clickbait title, it was a joke, I swear!

borkdude11:04:27

clj-kondo has now been released with the new linter config so you can express your concern about satisfies? and any other clojure var to your team members :)

genRaiy12:04:16

@U04V15CAJ I had to fork the prepl 😢

genRaiy12:04:28

To get this data

genRaiy12:04:37

:prepl-output {:tag :err, :val Reflection warning, NO_SOURCE_PATH:1:1 - reference to field toString can't be resolved.
, :user #:replacement.specs.user{:name test-user, :uid uid0}, :input (.toString (identity "foo"))}
:prepl-output {:tag :ret, :val "foo", :ns user, :ms 0, :form ^{:line 1, :column 1} (.toString ^{:line 1, :column 12} (identity "foo")), :user #:replacement.specs.user{:name test-user, :uid uid0}, :input (.toString (identity "foo"))}

genRaiy12:04:30

It turns out that certain errors are not flushed (ref https://clojure.atlassian.net/browse/CLJ-2645). So the only fix is a fork.

genRaiy12:04:16

But it means that when one evals a form it's trivial to associate reflection warnings with it. Then, since it's just data, the UI can surface it in any way it likes. It's not done yet but it's on the list.

plexus12:04:39

> @U07FP7QJ0 just read the implementation 😅 Looks like something that could really benefit from some caching

Ben Sless12:04:01

you can't cache it because you can extend-protocol 🙃

plexus12:04:48

Still, could be a production flag, -J-Dclojure.cache-protocols=true

Ben Sless12:04:47

Sounds like a good ask issue

borkdude13:04:23

Another solution would be to cache in user space

plexus13:04:45

sure, that's always an option, but it would be nice if it did the smart thing by default. There's plenty of prior art for this. Ruby keeps a method cache on the class, which gets invalidated if you reopen the class.

borkdude13:04:08

In CLJS there is a cheaper alternative to satisfies? called implements? which covers a subset of satisfies

borkdude13:04:54

instance? often works too in Clojure for a subset of cases

borkdude13:04:38

Another alternative (if you're looking for a specific home-made protocol) is to add a method to the protocol that returns true on implementations and false on Object and nil.

borkdude13:04:48

It's always good to enumerate alternatives

plexus13:04:18

I don't think that would help? they both have to go through find-protocol-impl. It's not specifically satifies? that's slow, it's find-protocol-impl which is used in satisfies?

plexus13:04:44

> In CLJS there is a cheaper alternative to satisfies? called implements? which covers a subset of satisfies ooh interesting, I guess I've seen implements? but never gave it much thought. I need to look into this.

plexus13:04:16

and one for my "differences between clj and cljs list" which maybe one day will become a blog post

plexus13:04:34

if I can remember in which org file I had that list 🙈

borkdude13:04:38

> I don't think that would help? It would be an alternative to satisfies? as you're not going through find-protocol-impl anymore (I think)

borkdude13:04:01

and protocol method invocations are cached on call sites (I think)

borkdude13:04:34

Ben will correct me if I'm wrong I hope

plexus13:04:36

ohhh so they do cache invocations, just not satisfies?... even more reason to cache satisifes? as well

borkdude13:04:51

A possible answer could be: if you're using satisfies? on a hot path, maybe you shouldn't. Just playing core devil's advocate ;)

borkdude13:04:32

One more difference with CLJS is that satisfies? in CLJS is a macro, so the type argument is static

borkdude13:04:10

(Most of this I know because I ran into these issues in SCI)

plexus13:04:38

aha, one more for the list 🙂

plexus13:04:51

Fogus replied! > I think a proposal for a caching scheme would be welcomed. I'll log a ticket as a place to discuss further in a bit.

Ben Sless13:04:12

iirc there's a jira ticket for a different implementation of satisfies? altogether

otfrom20:04:57

I hope I'm being mocked with love 😉

❤️ 1