Search Haskell Channel Logs

Monday, February 27, 2017

#haskell channel featuring raza, fryguybob, hboats_, peddie, Sornaensis,

hboats_ 2017-02-27 15:47:22
Sornaensis: I was messing around with something similar with a priority queue, there were a few papers on it, but they required a sort of global time clock. I think Aivika had something similar for one of its queues
Sornaensis 2017-02-27 15:47:47
I'm just doing a naive implementation with TMVars
Sornaensis 2017-02-27 15:48:01
based on the paper behind Java's SynchronousQueue class
fryguybob 2017-02-27 15:50:11
Sornaensis: Haskell STM is close to lock-free, but there is a narrow window that allows for live-locking in some situations. I could be fixed though :D.
Sornaensis 2017-02-27 15:51:25
fryguybob: like where transactions keep getting reordered?
fryguybob 2017-02-27 15:53:29
Sornaensis: Two transactions (in the right circumstances) can cause each other to fail to commit and the *both* start again.
Sornaensis 2017-02-27 15:53:50
hmm
Sornaensis 2017-02-27 15:53:58
what are the right circumstances
fryguybob 2017-02-27 15:54:00
Sornaensis: If the conflict allowed one of the transactions to continue then it would be lock-free.
Sornaensis 2017-02-27 15:54:43
could livelock occur with the usual usage of a TQueue
fryguybob 2017-02-27 15:54:47
Sornaensis: A simple example would be t0: read x write y and t1: read y write x
Sornaensis 2017-02-27 15:54:48
?
Sornaensis 2017-02-27 15:54:56
ah
Sornaensis 2017-02-27 15:55:16
fryguybob: are there any online resources that discuss the gotchas of STM
fryguybob 2017-02-27 15:55:32
Sornaensis: But they both have to hit their commit at the right time for this "both die" outcome.
peddie 2017-02-27 15:57:41
fryguybob: why in particular do those two conflict? what's a similar example that can't have this livelock issue?
fryguybob 2017-02-27 15:57:50
Sornaensis: There are some details in the commentary, but I can't think of a high-level resource that talks about much. I'm not sure I would call this a gotcha...
fryguybob 2017-02-27 15:58:15
Oh, sorry that was answering peddie
fryguybob 2017-02-27 15:58:39
No, my mistacke again :D
Sornaensis 2017-02-27 15:59:06
hmmm
Sornaensis 2017-02-27 15:59:18
fryguybob: can this occur with general use of a TQueue
fryguybob 2017-02-27 15:59:22
peddie: If you search for "live-lock" in the commentary: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/STM
peddie 2017-02-27 15:59:26
thanks fryguybob
Sornaensis 2017-02-27 15:59:30
just putting items on and taking them off of a TQueue
fryguybob 2017-02-27 15:59:40
There is a table that shows this particular example worked out.
raza 2017-02-27 16:00:29
hey haskell folks, how to export code+result for all source code blocks? I know I can use "export" option on a per source code block basis, but I want a global knob to switch.
fryguybob 2017-02-27 16:00:30
Sornaensis: I'll have to think about it.
raza 2017-02-27 16:00:41
this is for org-mode
raza 2017-02-27 16:00:50
let me know if it's the wrong forum
fryguybob 2017-02-27 16:01:11
Sornaensis: The bigest gotcha of STM is that there isn't fairness in GHC's implementation.
fryguybob 2017-02-27 16:02:15
So long running or large transactions can have difficultly commiting as short fast transactions are allowed to commit if they can.
Sornaensis 2017-02-27 16:02:48
neat
fryguybob 2017-02-27 16:03:29
Sornaensis: But fairness can slow things down quite a lot...
fryguybob 2017-02-27 16:06:56
Sornaensis: I don't think you can trigger live-locking with a single TQueue.
Sornaensis 2017-02-27 16:07:31
fryguybob: ah ok
raza 2017-02-27 16:13:52
have you guys used org-mode?
peddie 2017-02-27 16:14:42
raza: sounds like a question for #emacs