Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-21 Thread Plínio Balduino
So, as Andy pointed, transients would do the trick for you. And maybe type hints could also help but, as Stuart said, benchmark it all the way down. Regards Plinio On Wednesday, April 20, 2016, JvJ wrote: > I don't think I'll go with primitive arrays. A big part of the

Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread JvJ
I don't think I'll go with primitive arrays. A big part of the reason I'm using Clojure is for the immutable persistence. I just want to use them in the most efficient way possible. I know I'm not going to get hyper-blazing C-level performance. On Wednesday, 20 April 2016 15:38:11 UTC-7,

Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread Stuart Sierra
The first answer: test & measure. Benchmark your code, use a JVM profiler to find hotspots, etc. Test every change you make to see if it has a measurable improvement. Any assumptions about what “should” be faster/slower are likely to be wrong. The long answer: The JVM does not give you much

Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread Raoul Duke
You can only tell by benchmarking. And even then it can change when you move to different hardware. You can debate about big O and constant factors and numa and all that jazz till you are blue in the face. There are 3 kinds of people in the world: 1) those who think we should stick with arrays

Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread JvJ
Do you think that maps vs vectors would make a difference in the transient case? On Wednesday, 20 April 2016 13:42:12 UTC-7, Andy Fingerhut wrote: > > Transients are a performance optimization that can give quite significant > performance increases when you know you will be doing many updates

Re: Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread Andy Fingerhut
Transients are a performance optimization that can give quite significant performance increases when you know you will be doing many updates to a Clojure vector or map. A long sequence of updates on a transient tends to allocate much less memory than the corresponding sequence of updates on a

Memory Locality - Maps vs. Vectors vs. Transient Maps & Vectors

2016-04-20 Thread JvJ
I'm writing some code that I would like to perform as quickly as possible. Currently, I am iterating over large hash maps and performing assocs and dissocs. I don't know much about performance optimization, but I am told that memory locality is a big factor. I would like to know how