2009 June 22

Control.Monad.Queue

Haskell aficionados, take note! My library for corecursive queues has now been uploaded to Hackage. You can now cabal-install it.

I also have a substantially revised draft of the associated paper, Lloyd Allison’s Corecursive Queues, available. It has been re-organized so that it is hopefully easier to follow, it includes a careful performance comparison, and a tentative proof that mapCont cannot be expressed in terms of callCC, (>>=), return.

The library includes a somewhat crude micro-benchmarking program in the tests/ directory. Those who have read previous drafts, be warned that the few brief statements about performance were based on past notes, and I found some several issues with the testing methodology contained in the notes. Here the revised results:

Description

Time (ms)

-H500M

Bytes allocated

GHC 6.10.3

mean

σ

mean

σ

per Branch

levelOrder’

446

5

172

15

44.0

CorecQ

555

5

619

4

133.5

CorecQW _

696

5

1128

6

213.6

CorecQW ()

907

56

2235

11

213.6

Side Channel _

959

3

1171

7

228.7

Side Channel ()

1500

56

2171

7

276.4

STQ

1140

8

1087

14

371.2

TwoStack

1158

4

778

10

185.8

Okasaki

1553

7

1574

12

209.0

Data.Sequence

962

5

1308

5

348.1

GHC 6.8.3

levelOrder’

461

2

173

15

44.1

CorecQ

458

4

267

13

67.5

CorecQW _

526

5

713

5

141.2

CorecQW ()

781

62

1775

62

141.3

These benchmarks come from performing breadth-first traversals repeatedly on the 34th fibonacci tree, on an Intel Core 2 Duo T9550. The first few data points were discarded, and the mean and standard deviation of the remaining times were computed. Note that getCPUTime was used to time each run, and this has a resolution of only 10 milliseconds.

If you would like to play with the queue transformer, which doesn’t appear in the library, or other bits of code exactly as they appear in the paper, you can download the source code here.