<div style="height: initial;" dir="auto">I've got an interesting puzzle I'm pulling my hair out over.<div><br></div><div>I'm writing (pure functional) Haskell bindings for a C library which returns 2 large arrays of 32bit words (or rather arrays of structs, all of who's fields are very conveniently aligned). But these bindings I wrote are far too slow for my uses.</div><div><br></div><div>A primary performance problem identified by clear box benchmarking are a couple calls to `peekArray`. I've previously used `forM [0..length - 1] $ peekOffset arr`, but switching away from that yielded only minor performance benefit. Commenting out this `peekArray` removes all the overhead I'm seeing.</div><div><br></div><div>(Strangely commenting out any usage of the returned list does likewise, even though I've verified that the whole list doesn't get iterated over in WHNF)</div><div><br></div><div>The same benchmarks indicate that the postprocessing I'm applying over those lists has imperceptible overhead.</div><div><br></div><div>In short: What's the fastest `peekArray` alternative for `Ptr Word32` you recommend?</div><div><br></div><div>P.S. I'm inputting a nearly 1mb novel (Dracula by Bram Stoker) to get an estimated 20mb * 2 worth of output.</div></div>