Speed up unsafeInterleaveIO
AbandonedPublic

Authored by dfeuer on May 3 2017, 11:42 AM.

Details

Summary

Use an MVar and a "null pointer" trick I learned from Edward
Kmett to try to make unsafeInterleaveIO faster in the threaded
runtime, where noDuplicate# is not always cheap.

dfeuer created this revision.May 3 2017, 11:42 AM
rwbarton added inline comments.May 3 2017, 11:59 AM
libraries/base/GHC/IO/Unsafe.hs
134

Is this just trying to test whether two MutVar#s are the same? Use sameMutVar#.

dfeuer updated this revision to Diff 12375.May 3 2017, 1:34 PM

Simplify; remove module import loop

rwbarton requested changes to this revision.May 3 2017, 1:34 PM

In any case this code is incomprehensible as written.

This revision now requires changes to proceed.May 3 2017, 1:34 PM

I still don't understand what's going on here but if the aim is to save allocating 2 words per unsafeInterleaveIO then let's not do it.

dfeuer abandoned this revision.May 3 2017, 1:48 PM

I still don't understand what's going on here but if the aim is to save allocating 2 words per unsafeInterleaveIO then let's not do it.

Yes, that was the point. But you're probably right about it not being worth it. I'll focus on the Maybe-based version.