Fork me on GitHub
#cljs-dev
<
2021-04-12
>
Roman Liutikov12:04:01

not directly related to cljs dev, but have anyone noticed any performance regressions in Safari/JSC recently? IIRC JSC used to be the most performant engine when benchmarking cljs

raspasov12:04:08

@roman01la I haven’t anecdotally, but haven’t done any benchmarks (I run CLJS on JSC with iOS/React Native ). Have you noticed anything?

Roman Liutikov12:04:06

not sure yet, Safari's devtools doesn't help much to answer the question. Btw is there a way to install an older version of the browser on macOS?

raspasov13:04:27

Not sure, if I have to guess - no.

dnolen13:04:35

@roman01la I haven't checked recently - what are you observing?

dnolen13:04:16

to be clear what I observed was that functional patterns didn't lose

dnolen13:04:23

core.logic was fastest on JSC

dnolen13:04:48

I think self-hosted had the edge there but not huge

dnolen13:04:15

if you looked at persistent data structures directly I think the gap wasn't so significant between JSC & V8

dnolen13:04:37

but JSC was definitely faster

dnolen13:04:47

and surprisingly close to Clojure JVM

raspasov13:04:07

One thing I learned recently is that JSC apparently doesn’t JIT inside of React Native. Only in Safari. Not sure what the implication of that is (if any).

dnolen13:04:34

that's always been true

dnolen13:04:45

hasn't had any meaningful impact on RN adoption

dnolen13:04:02

the interpreters in JSC are not slow

dnolen13:04:20

well the one right before the JIT anyway

dnolen13:04:30

there's a bunch of levels

dnolen13:04:05

RN in general is UI stuff

raspasov13:04:07

Yes, it’s not new 🙂 I just recently learned that there’s (some) difference between what iOS does inside of Safari and RN. I used to think “it’s the same”.

dnolen13:04:09

not inner loop stuff

dnolen13:04:24

so for many apps - can't possibly matter

raspasov13:04:09

Yea, I don’t have perf. problems per se. Phones getting faster and faster each year; For most UI stuff you can’t tell the difference at all. And with stuff like Reanimated V2, things really fly anyway (even for UI animation).

dnolen13:04:16

in theory it could impact the PD (persisten data structure) stuff

dnolen13:04:29

but again, the amount of data you can present to a UI

dnolen13:04:34

on a phone is TINY

👍 3
dnolen13:04:17

probably tablets might matter

dnolen13:04:29

but tablets are getting as fast if not faster than laptops

raspasov13:04:34

Why tablets specifically?

dnolen13:04:44

you can present more data

dnolen13:04:48

more components etc.

raspasov13:04:00

Yeah… still maybe 2x more; not that different.

Roman Liutikov13:04:01

I'm observing marginally slower runtime performance, but don't want to blame JSC at this point. Either Safari's DevTools are not reliable at tracing or there's something else.

raspasov13:04:07

Are you running in browser, RN, or else?

Roman Liutikov13:04:06

but I've just asked, maybe someone knows something, don't want to spend anyones time on that, thanks 🙏

raspasov13:04:48

No problem 👍 clojure-spin

lilactown18:04:09

I think I found a bug in transient array map:

ClojureScript 1.10.844
cljs.user=> (def t (transient {}))
#'cljs.user/t
cljs.user=> (doseq [n (range 10)] (assoc! t n n))
nil
cljs.user=> (persistent! t)
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7}

lilactown18:04:41

it seems like any assoc! after the transient array map has 8 entries are just dropped

borkdude18:04:27

@lilactown This is not a bug, you should always use the return value from transient ops, not rely on their side effects

thheller18:04:17

yeah assoc! still has the same rules as assoc, must use the returned value

lilactown18:04:22

I see. so I'm inferring that what occurs is at > 8 entries it gets promoted to something other than an array map and thus breaks

thheller18:04:29

same problem will occur with hash maps, vectors etc. you cannot mutate in place safely

dpsutton18:04:36

> Transients support a parallel set of 'changing' operations, with similar names followed by ! - assoc!, conj! etc. These do the same things as their persistent counterparts except the return values are themselves transient. Note in particular that transients are not designed to be bashed in-place. You must capture and use the return value in the next call. https://clojure.org/reference/transients if you wanted to read where that is mentioned

raspasov18:04:42

I know the Clojure transients are much faster, but how do ClojureScript transients work? Do they use JavaScript objects underneath?

thheller18:04:13

they work exactly like in CLJ

3
raspasov18:04:34

I meant implementation-wise 🙂

thheller18:04:31

they work like the persistent versions, just mutate in place instead of doing the structural sharing thing

raspasov18:04:04

Ah I see; use the same data structure, but mutate in place rather than path copy; Got it.

raspasov18:04:11

Yeah that makes sense (doh); otherwise you wouldn’t be able to achieve O(1) transition to a persistent version;