Search Haskell Channel Logs

Tuesday, February 21, 2017

#haskell channel featuring kgadek_, ezyang, bollu, ertes, merijn,

ezyang 2017-02-20 23:58:06
The second scheme is more indirect
ezyang 2017-02-20 23:58:26
In the first scheme, you directly access the IORef stored in the data structure
ezyang 2017-02-20 23:58:34
In the second scheme, you have to go through the closure to get to the IORef
ezyang 2017-02-20 23:58:52
Although, this is all a bit specious because IORefs are hella indirect to begin with
ertes 2017-02-21 00:01:00
ezyang: yeah, that doesn't really matter… could as well be any other value
ertes 2017-02-21 00:01:20
ezyang: so you would expect the same?
ezyang 2017-02-21 00:02:17
Well, yes
ezyang 2017-02-21 00:02:26
Also if you're storing the functions, that's dynamic dispatch
ertes 2017-02-21 00:04:41
ezyang: what does that entail? i would expect it to require function pointers instead of known addresses, but x86 is reasonably good at dealing with those
ezyang 2017-02-21 00:05:23
The greatest cost of indirection is not so much the jump, but the inability of GHC to inline the target
ertes 2017-02-21 00:05:33
ah, yes
ertes 2017-02-21 00:05:36
good point
bollu 2017-02-21 00:06:42
ezyang: I am trying to understand how to optimise STG. Doesn't every continuation incur an indirect jump as it is a function pointer?
ezyang 2017-02-21 00:07:17
bollu: Yes? But only if you're passing around the continuation explicitly
bollu 2017-02-21 00:07:35
ezyang: but, like, inside STG, isn't "everything a continuation"?
ezyang 2017-02-21 00:08:01
..err, not really?
bollu 2017-02-21 00:09:05
ezyang: hm, OK
ertes 2017-02-21 00:09:21
i think STG only has TCO "built-in" in a sense
bollu 2017-02-21 00:09:26
ezyang: I was of the understanding that the "tagless" implied that nothing is tagged. Rather, one simply executes the function pointer
ertes 2017-02-21 00:10:13
as in: in something like (f (g x)), g is more likely to jump directly to f
ertes 2017-02-21 00:10:33
this might seem like CPS, but it's not
ezyang 2017-02-21 00:10:36
bollu: Oh, well, GHC doesn't actually implement tagless design haha
bollu 2017-02-21 00:10:52
ezyang: oh, interesting xD
bollu 2017-02-21 00:10:59
ezyang: OK, so what does GHC implement?
ezyang 2017-02-21 00:11:01
http://simonmar.github.io/bib/papers/ptr-tagging.pdf
bollu 2017-02-21 00:11:28
ezyang: oh, OK, thanks
bollu 2017-02-21 00:11:35
ezyang: one more thing to read :P
ezyang 2017-02-21 00:11:52
this paper is "more modern" than the STG paper, so it should be easier
ezyang 2017-02-21 00:31:38
an unevaluated thunk will always need an indirect jump
ertes 2017-02-21 00:32:09
i see
ezyang 2017-02-21 00:32:28
note that GHC's optimizer will try to eliminate thunks as much as possible
kgadek_ 2017-02-21 00:34:20
ezyang: you mean strictness analyser or other part of optimiser (all parts?)
ezyang 2017-02-21 00:34:38
strictness analyzer mostly, I think!
merijn 2017-02-21 00:35:13
I wonder how much of GHC's machinery could be lifted out and made Haskell agnostic (i.e., the Core->STG->Cmm->LLVM pipeline)