This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-09
Channels
- # announcements (5)
- # beginners (53)
- # clj-kondo (4)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsjs (1)
- # clojure (59)
- # clojure-europe (15)
- # clojure-italy (6)
- # clojure-nl (9)
- # clojure-spec (22)
- # clojure-uk (26)
- # clojurescript (16)
- # clojutre (6)
- # cursive (27)
- # datomic (34)
- # duct (1)
- # figwheel-main (2)
- # fulcro (12)
- # graphql (14)
- # jackdaw (9)
- # jobs (1)
- # kaocha (4)
- # luminus (1)
- # off-topic (11)
- # pathom (1)
- # pedestal (2)
- # re-frame (6)
- # reagent (10)
- # ring-swagger (34)
- # shadow-cljs (47)
- # spacemacs (21)
- # sql (3)
- # tools-deps (37)
- # uncomplicate (11)
- # vim (17)
I have no use case for such a thing, but was curious whether anyone had considered storing Clojure data structures, e.g. vectors, maps, sets, inside of a Web Worker shared buffer? I guess not just considered, but actually tried it, and/or looked at any changes in the ClojureScript implementation that would be required to support it?
(Admittedly many years ago now. Since then structured cloning and dataview apis have gotten faster, maybe the situation is different now)
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
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.
To really leverage sharedbuffer would require some in-memory layout for cljs data structures like eg captnproto (and some memory management!)
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.
Java/Clojure concurrency is mostly about publishing pointer updates assuming all memory is shared
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
So I doubt anyone has done this in cljs land because the problem doesn’t even make sense
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.