Re: data structure creation time in cljs
I've just updated benchmark dependencies to reflect latest changes in ClojureScript. Keywords are little slower than before but otherwise there are no big differences. JW On Wednesday, November 6, 2013 5:04:26 AM UTC+1, kovasb wrote: FYI, http://wagjo.github.io/benchmark-cljs/ has some interesting cljs perf comparisons for various datastructures, for those who haven't seen it. On Tue, Nov 5, 2013 at 10:38 PM, kovas boguta kovas@gmail.comjavascript: wrote: I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
Some good news and some puzzling news. With advanced mode, the various forms of non-literal vector creation clock in around 400msec for 1 million ops on node, which is a 2-to-5x improvement. Now, the puzzling bit: Using time, I get a big fat 0 for certain kinds of operations: (time (dotimes [x 100] (Test. x))) -- big fat 0 Again this is on node, running the script from the command line. There also seems to be some issue with laziness, where some of my big list operations are getting a 0 as well. Is advanced mode somehow optimizing these things away because they don't get used elsewhere in the program? Pretty confusing. On Tue, Nov 5, 2013 at 11:21 PM, David Nolen dnolen.li...@gmail.com wrote: Yes no benchmarking with anything other than advanced please - lots of optimizations kick in only for :advanced, especially around various forms of function invocation, :simple + :static-fns true will also give reasonable results however it'll mess with REPL interactivity. David On Tue, Nov 5, 2013 at 11:13 PM, kovas boguta kovas.bog...@gmail.com wrote: On Tue, Nov 5, 2013 at 11:05 PM, David Nolen dnolen.li...@gmail.com wrote: Also what optimization settings are you using? I guess I should try something other than the browser repl. Will retry with advanced optimizations. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
On Wed, Nov 6, 2013 at 7:36 PM, kovas boguta kovas.bog...@gmail.com wrote: There also seems to be some issue with laziness, where some of my big list operations are getting a 0 as well. Alright I managed to figure out my laziness issue, but the thing with records is still a head-scratcher... -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
Yes Closure is smart enough to remove code that doesn't do anything. Try with :simple and :static-fns true On Wednesday, November 6, 2013, kovas boguta wrote: On Wed, Nov 6, 2013 at 7:36 PM, kovas boguta kovas.bog...@gmail.comjavascript:; wrote: There also seems to be some issue with laziness, where some of my big list operations are getting a 0 as well. Alright I managed to figure out my laziness issue, but the thing with records is still a head-scratcher... -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.comjavascript:; 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 javascript:; For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:;. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
`vector` is now inlined in master, should be 10X faster for (vector 1) David On Tue, Nov 5, 2013 at 10:38 PM, kovas boguta kovas.bog...@gmail.comwrote: I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
data structure creation time in cljs
I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
FYI, http://wagjo.github.io/benchmark-cljs/ has some interesting cljs perf comparisons for various datastructures, for those who haven't seen it. On Tue, Nov 5, 2013 at 10:38 PM, kovas boguta kovas.bog...@gmail.com wrote: I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
If anything is an order of magnitude slower than Clojure it should be considered a bug and be filed as such. We're shooting for w/in 2.5X for all operations. `vector` is slow and can easily be dramatically improved. I suspect there's something up with record creation and it should be looked into. You might want to compare with construction time of a deftype instance, I see little reason why records can't be constructed as quickly. Also what optimization settings are you using? David On Tue, Nov 5, 2013 at 10:38 PM, kovas boguta kovas.bog...@gmail.comwrote: I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
This is really cool, would love to have something like this combined with graphs like the old ClojureScript benchmarks where we tracked based on git commit for the major JS engines. David On Tue, Nov 5, 2013 at 11:04 PM, kovas boguta kovas.bog...@gmail.comwrote: FYI, http://wagjo.github.io/benchmark-cljs/ has some interesting cljs perf comparisons for various datastructures, for those who haven't seen it. On Tue, Nov 5, 2013 at 10:38 PM, kovas boguta kovas.bog...@gmail.com wrote: I'm trying to optimize zippers for clojurescript. My benchmark is implementing the combinator systems from https://www.wolframscience.com/nksonline/page-102 which heavily stress both navigating and modifying the tree. A major hotspot seems to be data structure creation time, which can be between 10 and 200x slower than jvm. I'm using Chrome 30.0.1599.101 . Vectors: (time (dotimes [x 100] ( vector x))) cljs: 2175 msecs clj: 11.414 msecs strangely, apply is faster for cljs : (time (dotimes [x 100] (apply vector [x]))) cljs: 1175 msecs clj: 64.919 msecs into gives about the same result for cljs. Creating a datastructure literal (eg [x]) is about 5x slower in cljs over clj, which I would take, however in the zipper case the number of children can vary dynamically. Lists: (apply list [x]) is about 2x faster than the vector case in cljs, and within about 5x of the jvm speed. Unless there is a better idea, I may try a specialized list-oriented zipper and see how it performs. Records: Creation is about ~10x slower than in clj. What's weird is that creating hashmaps is actually marginally faster than creating records (however, records still have much faster field access, so I'm using a record-based zipper implementation) (defrecord Test [a]) (time (dotimes [x 100] (Test. x))) cljs: 60 msecs clj: 7.00 msecs Is there a trick to speed up vector and/or record creation? Should I look into a custom datastructure? Any ideas welcome. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
On Tue, Nov 5, 2013 at 11:05 PM, David Nolen dnolen.li...@gmail.com wrote: Also what optimization settings are you using? I guess I should try something other than the browser repl. Will retry with advanced optimizations. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: data structure creation time in cljs
Yes no benchmarking with anything other than advanced please - lots of optimizations kick in only for :advanced, especially around various forms of function invocation, :simple + :static-fns true will also give reasonable results however it'll mess with REPL interactivity. David On Tue, Nov 5, 2013 at 11:13 PM, kovas boguta kovas.bog...@gmail.comwrote: On Tue, Nov 5, 2013 at 11:05 PM, David Nolen dnolen.li...@gmail.com wrote: Also what optimization settings are you using? I guess I should try something other than the browser repl. Will retry with advanced optimizations. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.