Let's try this again. Maybe the question is what is the most performant way to consume a native java collection (List, array, or other) in clojure? What I've tried so far hits clojure-imposed performance issues. How do I get to near-java performance? I'm trying to create a polemic for clojure and "the java version of this program is 30% faster" isn't where I want to start. Am I missing something?
On Monday, June 17, 2013 3:34:07 PM UTC-7, Tim Jones wrote: > > I'm working on a small clojure program which pulls data from a custom > memory-backed data store via a java api. When looking at performance, > there is a hotspot at the point of interaction with this API. One of the > fields of each record being exported contains a list of lists of strings > (List<List<String>>) with about 60-150 items in the outer list and 5 items > in the inner list. The problem is that at the point of assimilating this > java data type into clojure, there are a couple calls taking ~30-40% of the > execution time. Here are the senarios; I'm just starting to get familiar > with clojure internals, so forgive obvious blunders in this. > > Processing it as: > > (map parse-field (.getAllFields datastore)) > > with parse-field defined like: > > (defn parse-field [^List field] ...) > > or (if I change the API call) > > (defn parse-field [^"[Ljava.lang.String;" field] ...) > > it calls clojure.lang.RestFn.invoke() which wants to build an ArraySeq, > which calls java.lang.Class.getComponentType, which is a killer (20 of 50 > seconds on 500 records). > > With parse-field using destructuring, on either the List or String array, > clojure.lang.RT.nthFrom() is invoked, which calls java.lang.Class.isArray ( > https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L773), > > which is a killer as well. > > So I inlined parse-field and used loop/recur (instead of map) and .get on > the list to get the next item, but this still results in the > RestFn.invoke()->ArraysSeq->Class.getComponentType path. > > This is related to http://dev.clojure.org/jira/browse/CLJ-1200, although > called via a different path. > > Does anyone have any ideas on how I could avoid these calls? > > Thanks, > > Tim > > -- -- 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.