Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-27 Thread Janek S.
I tested the same code on my second machine - Debian Squeeze (kernel 2.6.32) with GHC 7.4.1 - and the results are extremely surprising. At first I was unable to reproduce the problem and got consistent runtimes of about 107us: benchmarking FFI/C binding mean: 107.3837 us, lb 107.2013 us, ub

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-27 Thread Jake McArthur
I once had a problem like this. It turned out that my laptop was stepping the cpu clock rate down whenever it got warm. Disabling that feature in my BIOS fixed it. Your problem might be similar. On Nov 27, 2012 7:23 AM, Janek S. fremenz...@poczta.onet.pl wrote: I tested the same code on my

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-27 Thread Janek S.
Dnia wtorek, 27 listopada 2012, Jake McArthur napisał: I once had a problem like this. It turned out that my laptop was stepping the cpu clock rate down whenever it got warm. Disabling that feature in my BIOS fixed it. Your problem might be similar. I just check - I disabled frequency scaling

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-27 Thread Gregory Collins
Did you pass the option to criterion asking it to do a GC between trials? You might be measuring a GC pause. On Tue, Nov 27, 2012 at 2:41 PM, Janek S. fremenz...@poczta.onet.pl wrote: Dnia wtorek, 27 listopada 2012, Jake McArthur napisał: I once had a problem like this. It turned out that my

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-27 Thread Janek S.
Dnia wtorek, 27 listopada 2012, Gregory Collins napisał: Did you pass the option to criterion asking it to do a GC between trials? Yes. You might be measuring a GC pause. On Tue, Nov 27, 2012 at 2:41 PM, Janek S. fremenz...@poczta.onet.pl wrote: Dnia wtorek, 27 listopada 2012, Jake

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-25 Thread Janek S.
Well, it seems that this only happens on my machine. I will try to test this code on different computer and see if I can reproduce it. I don't think using existing vector is a good idea - it would make the code impure. Janek Dnia sobota, 24 listopada 2012, Branimir Maksimovic napisał: I

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-24 Thread Janek S.
I'm using GHC 7.4.2 on x86_64 openSUSE Linux, kernel 2.6.37.6. Janek Dnia piątek, 23 listopada 2012, Edward Z. Yang napisał: Running the sample code on GHC 7.4.2, I don't see the one fast, rest slow behavior. What version of GHC are you running? Edward Excerpts from Janek S.'s message of

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-24 Thread Branimir Maksimovic
I don't see such behavior neither.ubuntu 12.10, ghc 7.4.2. Perhaps this has to do with how malloc allocates /cachebehavior. If you try not to allocate array rather use existing one perhaps there would be no inconsistency?It looks to me that's about CPU cache performance. Branimir I'm using

[Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-23 Thread Janek S.
I am using Criterion library to benchmark C code called via FFI bindings and I've ran into a problem that looks like a bug. The first benchmark that uses FFI runs correctly, but subsequent benchmarks run much longer. I created demo code (about 50 lines, available at github:

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-23 Thread Edward Z. Yang
Hello Janek, What happens if you do the benchmark without unsafePerformIO involved? Edward Excerpts from Janek S.'s message of Fri Nov 23 10:44:15 -0500 2012: I am using Criterion library to benchmark C code called via FFI bindings and I've ran into a problem that looks like a bug. The

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-23 Thread Janek S.
What happens if you do the benchmark without unsafePerformIO involved? I removed unsafePerformIO, changed copy to have type Vector Double - IO (Vector Double) and modified benchmarks like this: bench C binding $ whnfIO (copy signal) I see no difference - one benchmark runs fast, remaining

Re: [Haskell-cafe] Problem with benchmarking FFI calls with Criterion

2012-11-23 Thread Edward Z. Yang
Running the sample code on GHC 7.4.2, I don't see the one fast, rest slow behavior. What version of GHC are you running? Edward Excerpts from Janek S.'s message of Fri Nov 23 13:42:03 -0500 2012: What happens if you do the benchmark without unsafePerformIO involved? I removed