Re: Slow image convolution

2012-11-10 Thread Cedric Greevey
On Fri, Nov 9, 2012 at 11:57 AM, Yakovlev Roman wrote: > what a mess if it is a function it's huuge did you try split it to useful > chunks ? it's just unreadable and that's why you cann't spot anything i > guess.. > I can't split it without ending up with boxing at the function call boundaries,

Re: Slow image convolution

2012-11-09 Thread Jim foo.bar
I thought 'definline' addresses exactly that...cases where one might want to pull out small pieces of first class functionality without sacrificing performance and without macros (which are not first-class)...am I mistaken? Jim ps: the only similarly big function that I've ever written (still

Re: Slow image convolution

2012-11-09 Thread Andy Fingerhut
Having worked on Clojure benchmarks on the Computer Language Benchmarks Game web site, that is sometimes the kind of Clojure code one needs to write if you want it to be as fast as it can be. http://shootout.alioth.debian.org/u64q/compare.php?lang=clojure Also, splitting it out into smaller

Re: Slow image convolution

2012-11-09 Thread Yakovlev Roman
what a mess if it is a function it's huuge did you try split it to useful chunks ? it's just unreadable and that's why you cann't spot anything i guess.. пятница, 9 ноября 2012 г., 0:48:20 UTC+4 пользователь Cedric Greevey написал: > > I have the following code to perform a complicated image co

Re: Slow image convolution

2012-11-09 Thread Andy Fingerhut
I haven't determined exactly why that particular code is slow for you, but I have looked at it for a few minutes and have some suggestions: 1. In Clojure 1.3 and later, the default integer type for primitive arithmetic is long, not int. Declaring things int means that they are really longs in t

Re: Slow image convolution

2012-11-08 Thread Cedric Greevey
So 100 million (rand) calls take 20 seconds. From temporarily changing ^BufferedImage chunk (chunk-cache chunk-num) to ^BufferedImage chunk nil, I determined that 100 million of the *combination* of the cache lookup (with no misses) and the .getRGB call took 30. That still leaves just over two minu

Re: Slow image convolution

2012-11-08 Thread Cedric Greevey
(rand) is expensive -- removing the two (rand)s knocks about 40 seconds off it, nearly 1/5 the total time. I'll try replacing them with lookup from a precalculated grid of randoms -- long-range correlations shouldn't matter here. On Thu, Nov 8, 2012 at 8:00 PM, Cedric Greevey wrote: > On Thu,

Re: Slow image convolution

2012-11-08 Thread Cedric Greevey
On Thu, Nov 8, 2012 at 3:48 PM, Cedric Greevey wrote: > I have the following code to perform a complicated image convolution. It > takes 10-15 seconds with output dimensions 256x256 and samples 6. No > reflection warnings, and using unchecked math doesn't speed it up any. I've > tried to ensure i