cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
2021-04-12T12:05:01.057900Z

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

raspasov 2021-04-12T12:44:08.059200Z

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

2021-04-12T12:45:06.059300Z

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?

dnolen 2021-04-12T13:25:35.059800Z

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

dnolen 2021-04-12T13:26:16.060400Z

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

dnolen 2021-04-12T13:26:23.060700Z

core.logic was fastest on JSC

raspasov 2021-04-12T13:26:27.060800Z

Not sure, if I have to guess - no.

dnolen 2021-04-12T13:26:48.061400Z

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

dnolen 2021-04-12T13:27:15.062200Z

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

dnolen 2021-04-12T13:27:37.062700Z

but JSC was definitely faster

dnolen 2021-04-12T13:27:47.063400Z

and surprisingly close to Clojure JVM

raspasov 2021-04-12T13:28:07.064Z

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

dnolen 2021-04-12T13:28:34.064800Z

that's always been true

dnolen 2021-04-12T13:28:45.065400Z

hasn't had any meaningful impact on RN adoption

dnolen 2021-04-12T13:29:02.065900Z

the interpreters in JSC are not slow

dnolen 2021-04-12T13:29:20.066400Z

well the one right before the JIT anyway

dnolen 2021-04-12T13:29:24.066600Z

or two

dnolen 2021-04-12T13:29:30.066900Z

there's a bunch of levels

dnolen 2021-04-12T13:30:05.067900Z

RN in general is UI stuff

raspasov 2021-04-12T13:30:07.068100Z

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

dnolen 2021-04-12T13:30:09.068200Z

not inner loop stuff

dnolen 2021-04-12T13:30:24.068600Z

so for many apps - can't possibly matter

raspasov 2021-04-12T13:31:09.070Z

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

dnolen 2021-04-12T13:31:16.070200Z

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

dnolen 2021-04-12T13:31:29.070700Z

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

dnolen 2021-04-12T13:31:34.071Z

on a phone is TINY

👍 1
dnolen 2021-04-12T13:32:17.071700Z

probably tablets might matter

dnolen 2021-04-12T13:32:29.072200Z

but tablets are getting as fast if not faster than laptops

raspasov 2021-04-12T13:32:34.072400Z

Why tablets specifically?

dnolen 2021-04-12T13:32:44.073100Z

you can present more data

dnolen 2021-04-12T13:32:48.073300Z

more components etc.

raspasov 2021-04-12T13:33:00.073700Z

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

2021-04-12T13:34:01.074700Z

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.

raspasov 2021-04-12T13:36:07.075600Z

Are you running in browser, RN, or else?

2021-04-12T13:37:40.075800Z

Browser

2021-04-12T13:39:06.076Z

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

raspasov 2021-04-12T13:40:48.076200Z

No problem 👍 :clojure-spin:

lilactown 2021-04-12T18:03:09.077400Z

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}

lilactown 2021-04-12T18:03:41.078100Z

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

borkdude 2021-04-12T18:04:27.078700Z

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

thheller 2021-04-12T18:05:17.079200Z

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

lilactown 2021-04-12T18:06:22.080300Z

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

thheller 2021-04-12T18:07:29.080900Z

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

dpsutton 2021-04-12T18:09:36.082400Z

> 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

raspasov 2021-04-12T18:09:42.082500Z

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

thheller 2021-04-12T18:10:13.082800Z

they work exactly like in CLJ

1
raspasov 2021-04-12T18:10:34.083200Z

I meant implementation-wise 🙂

thheller 2021-04-12T18:11:31.083900Z

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

raspasov 2021-04-12T18:12:04.084500Z

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

thheller 2021-04-12T18:12:09.084700Z

yes

raspasov 2021-04-12T18:13:11.085300Z

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