cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
favila 2019-09-10T01:17:20.067800Z

last time I checked transit to a string in a postMessage was much faster

favila 2019-09-10T01:19:40.069800Z

(Admittedly many years ago now. Since then structured cloning and dataview apis have gotten faster, maybe the situation is different now)

favila 2019-09-10T01:27:07.075200Z

Fressian-cljs and transit msgpack both exist in browser so in theory you could use shared buffers, but shared buffers offer nothing over arraybuffer transferin these cases

2019-09-10T01:27:55.076700Z

Background on my question: I am writing up an article on Java synchronization techniques used in the Clojure/Java implementation to ensure that data is written by one thread in a way that other threads are guaranteed to get the most up to date version. In the introduction I have written a brief note that these issues do not apply for single-threaded ClojureScript, and then remembered that Web Workers and shared memory proposals exist for JavaScript, and was curious if anything had been done in ClojureScript to take advantage of that.

favila 2019-09-10T01:28:19.077400Z

To really leverage sharedbuffer would require some in-memory layout for cljs data structures like eg captnproto (and some memory management!)

2019-09-10T01:29:45.078900Z

Makes sense. It certainly doesn't appear that doing what I asked about is any kind of sweet spot for any use case that anyone right now wants to write lots of tricky code for. I was primarily curious if anyone knew whether someone had tried going that route.

favila 2019-09-10T01:30:21.080Z

Java/Clojure concurrency is mostly about publishing pointer updates assuming all memory is shared

favila 2019-09-10T01:31:28.081900Z

In js, there’s no way to share a pointer, threads are already fully isolated. All sharing and concurrency features are concerned with zero-copy array/memory publishing and sharing

favila 2019-09-10T01:31:57.082800Z

So I doubt anyone has done this in cljs land because the problem doesn’t even make sense

2019-09-10T01:41:50.084Z

I mean, if someone wanted to get tricky, they could use integers in shared memory as indices into arrays, effectively using them like "pointers", so could create potential inter-thread synchronization problems.