lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
pesterhazy 2017-11-23T12:47:10.000074Z

@rauh, your snippet is interesting. I've had problems with using transit/read with regular JSON in the past. When values (not just keys) start with ^, the result is corrupted

pesterhazy 2017-11-23T12:47:17.000027Z

does the snippet fix that?

pesterhazy 2017-11-23T12:47:53.000229Z

we really need a fast "JSON-string => clj-data-structure" implementation

pesterhazy 2017-11-23T12:48:23.000125Z

js->clj is a real perf killer in my experience

rauh 2017-11-23T12:49:13.000200Z

@pesterhazy Yeah probably would also corrupt it. But if you delete these handler then it should be safe: https://gist.github.com/rauhs/301f59e0e2f94db4f22a4724fe50bd5f#file-parse-json-with-transit-cljs-L27-L36

rauh 2017-11-23T12:49:40.000349Z

IMO it would be pretty easy to write a super fast js->clj implementation. I just personally don't use it much so never bothered with it

pesterhazy 2017-11-23T12:50:31.000006Z

cool, thanks for the pointer

rauh 2017-11-23T12:50:33.000029Z

All you need to do is manually create a for look and create PAM/PV's from it.

pesterhazy 2017-11-23T12:50:50.000173Z

right

pesterhazy 2017-11-23T12:52:14.000108Z

might be a good weekend project

pesterhazy 2017-11-23T12:52:56.000392Z

some people dislike js->clj but IMO there's no alternative when you're consuming JSON data from a server as clj data structures

rauh 2017-11-23T12:55:01.000036Z

One start would be to speed up keyword, though it's probably not the main cost for js->clj: https://dev.clojure.org/jira/browse/CLJS-2120

pesterhazy 2017-11-23T13:02:46.000330Z

I'm sure it's part of it

rauh 2017-11-23T13:21:34.000064Z

@pesterhazy Benchmark this: https://gist.github.com/rauhs/c2f84c91ef311c1c080a93b852c50daa

pesterhazy 2017-11-23T14:11:17.000218Z

@rauh, what do you mean by "not for node"?

rauh 2017-11-23T14:11:57.000335Z

@pesterhazy It caches any key it sees, so somebody can attack your server and just send nonsense JSON with lots of random keys.

pesterhazy 2017-11-23T14:12:10.000286Z

ah because of security considerations

rauh 2017-11-23T14:12:12.000243Z

In CLJ they're weak refs and will be GC'd. In JS that doesn't exist

rauh 2017-11-23T14:12:36.000423Z

That's also the reason core doesn't do it. IIRC the first implementation actually did cache them

pesterhazy 2017-11-23T14:13:03.000259Z

the cache needs to have limit of N elements

rauh 2017-11-23T14:14:00.000367Z

Yeah, but that's pretty complicated to do. and might negate any perf benefits

pesterhazy 2017-11-23T14:14:21.000502Z

shouldn't be too hard

pesterhazy 2017-11-23T14:14:40.000163Z

you could have n Objects with m keys max

pesterhazy 2017-11-23T14:15:12.000297Z

once you reach n*m you can clear the first one again

pesterhazy 2017-11-23T14:15:27.000304Z

that might work for a lot of situations

rauh 2017-11-23T14:15:50.000275Z

I don't think it's that easy. NOw you have linear search. You'd need to store access tiem every time you access it. -> Overhead

rauh 2017-11-23T14:16:17.000244Z

And then walk it every time since JS doesn't give you a possibility to count the keys of an object (fast).

pesterhazy 2017-11-23T14:16:29.000236Z

really?

rauh 2017-11-23T14:16:33.000056Z

And now I'm already faster with a simple new keyword creation.

pesterhazy 2017-11-23T14:17:35.000069Z

Object.keys(o).length is not constant time?

pesterhazy 2017-11-23T14:18:45.000121Z

that's nuts

mfikes 2017-11-23T16:08:10.000006Z

@rauh FWIW, when I wrote http://blog.fikesfarm.com/posts/2017-11-09-avoid-converting-javascript-objects.html, I checked if :keywordize-keys true was affecting js->clj perf. It was not (a 1.1 speedup by disabling that). Compared that to to the overall speedup ranging between 26 and 68 by ditching js->clj as a whole and using goog.object/getValueByKeys). (See the post for details.)

mfikes 2017-11-23T16:09:43.000093Z

Well, it was affecting perf, but small compared to the gross perf stuff going on in js->clj

rauh 2017-11-23T16:09:49.000281Z

@mfikes Yeah my guess is that for and (vec (map ..)) are the main culprits. Just getting rid of those would likely be much faster

mfikes 2017-11-23T16:10:23.000311Z

FWIW https://dev.clojure.org/jira/browse/CLJS-2341 is an improvement js->clj

mfikes 2017-11-23T16:10:55.000135Z

It gets rid of for as you suggest

mfikes 2017-11-23T16:11:56.000436Z

Perhaps the (vec (map ...)) could be another fruitful perf avenue to pursue

rauh 2017-11-23T16:16:35.000186Z

@mfikes I wish we had a js-for to generate native for loops 😕

borkdude 2017-11-23T20:22:14.000121Z

@richiardiandrea FWIW, we have this kind of error message in our cljs build regularly: > Attempting to call unbound fn: #’clojure.spec.alpha/macroexpand-check at line 2529, column 11 in file /Users/Borkdude/.boot/cache/tmp/Users/Borkdude/dre/…/app/r0g/-tnd3jd/public/js/app.out/cljs/pprint.cljs I think I saw you talking about something similar here.

borkdude 2017-11-23T20:24:31.000094Z

It’s not reproducible. When we touch a source file, it recompiles and it’s fine.

richiardiandrea 2017-11-23T20:41:42.000167Z

@borkdude there is something going on there, it's been hard to track down and I haven't yet

borkdude 2017-11-23T20:42:18.000064Z

@richiardiandrea Do you perhaps have parallel build on, like we do?

borkdude 2017-11-23T20:42:25.000087Z

I wonder if it’s a race condition of some sort

richiardiandrea 2017-11-23T20:42:57.000148Z

talking about lumo only, where no parallel builds are done...so there might be some other race condition

richiardiandrea 2017-11-23T20:43:43.000092Z

(maybe in common with cljs)

borkdude 2017-11-23T20:44:34.000138Z

The error I posted here didn’t come from lumo, but I saw you posting something similar, so just sharing this fwiw

richiardiandrea 2017-11-23T20:49:45.000096Z

that's good thanks a lot, and you are not the first btw I think to notice that