Re: Some suggestions for transients
Oops didn't know that Rich had already answered. Google seems to think that our posts are commutative :/ (often they're not, or are they? I can't take a stand on this) and just uses the commute fn instead of using alter and failing the transaction (informing us); but it does allow for more concurrency as Rich mentions in the docs of commute :P. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Some suggestions for transients
On May 26, 5:13 pm, Michael Jaaka michael.ja...@googlemail.com wrote: Hi! I have some suggestions about transients (btw. thehttp://clojure.org/transients is not linked fromhttp://clojure.org). Maybe before you give up reading the whole post I will post as first the digression: vars binding and transient are similar, however in the first case we have thread isolation on reading and writing with reference covering/ hiding ability. Currently operations on transients structures seems to be badly interfaced in Clojure and below is a deal: Why do we have to deal with conj! and rest of foo! operations, when there are much more functions like update-in, assoc-in etc. what about them? In most my code I fail to use transient because of xyz-in operations. More over I know that the code is whole executed by one thread, since I know where the transient structure starts to exist and when it ends. Tracking such code is easy task to do since most fast compuations are free of side effects and thread intercommunication. If the whole talk is about thread isolation (which is great feature), then the interface should be simplified, in the way like - (transient x) - attaches thread (which calls transient) reference to my structure (object), when any other thread tries to modify x then the exception is thrown. When I do (persistent x), the thread reference is detached from the structure, so it becomes persistent and others threads can concurrently modify it. This would eleminate duplication of functions and allow for single threaded computations. This would satisfy most computations related with reduce operation and recurention. So easy to do, so easy to track, yet not in Clojure ;-(. The (transient x) and (persistent x) are required since the are explicit declaration of single thread mutation. Also it would be nice if such transient structures could be used in binding clasues, since I have found other adoption - for example thread is doing computations in a functional way - and with binded transients I'm gathering statistics (time measurement, bytes counting etc. in an imperative, side effecting, more like aspect way.) What are your thoughts? The problem is that the semantics of conj and conj! are quite different. The first promises to return a persistent immutable value and the second promises the opposite. BTW. What does it mean don't bash in place - since for not all people English is not a native language I suggest to use simpler words in such formulations. It means, modify in place by repeated interaction with the same object, as in OO: x.changeThis() x.changeThat() x.changeTheOther() or, in Clojure with a transient: ;;this is bad, don't do this (let [x (transient y)] (conj! x this) (conj! x that) (conj! x theOther)) the above Clojure structure would never arise by following the guidelines of writing it functionally first. Rich -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Some suggestions for transients
My 2 cents, I read about transients for the first time (why is the page not linked from clojure.org?) and they seem very promising at a first glance. I'm not sure if I agree with Michael's idea of having the same functions for transients and persistents both. Functions should have easy, reproducible semantics imo. If I take a look at a function call in isolation of its environment, I should be able to predict its semantics exactly, not in 90% cases, but 100% (maybe ideal, given my inexperience). But I do agree with his concern about the multitude of functions for persistents and very few for transients. If I want my bottleneck function to use transients, it should be straightforward. Else most of the energy would be spent to re write things like foo-in etc. But maybe that's a deliberate design decision take by Rich not to make transients popular? On the transients page Rich has given a very simple benchmark - (time (def v (vrange 100))) Elapsed time: 297.444 msecs (time (def v2 (vrange2 100))) Elapsed time: 34.428 msecs But on my system I don't get a ~9x performance boost, it mostly get a ~3x performance boost (1.2). Have there been some changes? What do other people get? (time (def v (vrange 100))) Elapsed time: 261.82 msecs (time (def v2 (vrange2 100))) Elapsed time: 87.3 msecs Michael: bash in place means in-place memory writing, for example in Java we have a Collections.sort(list) method which uses in-place merge sort. That method doesn't return a sorted list, it just changes the original list in place (which is more memory efficient). Hope I've been successful in conveying to you. - Thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Some suggestions for transients
Hi! I have some suggestions about transients (btw. the http://clojure.org/transients is not linked from http://clojure.org). Maybe before you give up reading the whole post I will post as first the digression: vars binding and transient are similar, however in the first case we have thread isolation on reading and writing with reference covering/ hiding ability. Currently operations on transients structures seems to be badly interfaced in Clojure and below is a deal: Why do we have to deal with conj! and rest of foo! operations, when there are much more functions like update-in, assoc-in etc. what about them? In most my code I fail to use transient because of xyz-in operations. More over I know that the code is whole executed by one thread, since I know where the transient structure starts to exist and when it ends. Tracking such code is easy task to do since most fast compuations are free of side effects and thread intercommunication. If the whole talk is about thread isolation (which is great feature), then the interface should be simplified, in the way like - (transient x) - attaches thread (which calls transient) reference to my structure (object), when any other thread tries to modify x then the exception is thrown. When I do (persistent x), the thread reference is detached from the structure, so it becomes persistent and others threads can concurrently modify it. This would eleminate duplication of functions and allow for single threaded computations. This would satisfy most computations related with reduce operation and recurention. So easy to do, so easy to track, yet not in Clojure ;-(. The (transient x) and (persistent x) are required since the are explicit declaration of single thread mutation. Also it would be nice if such transient structures could be used in binding clasues, since I have found other adoption - for example thread is doing computations in a functional way - and with binded transients I'm gathering statistics (time measurement, bytes counting etc. in an imperative, side effecting, more like aspect way.) What are your thoughts? Thanks, BTW. What does it mean don't bash in place - since for not all people English is not a native language I suggest to use simpler words in such formulations. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en