Wait, does that mean the corresponding constants in base for 7.8.3 are busted?<br><br>On Saturday, July 19, 2014, Jost Berthold <<a href="mailto:berthold@mathematik.uni-marburg.de">berthold@mathematik.uni-marburg.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Message: 2<br>
Date: Sat, 19 Jul 2014 15:00:17 +1000<br>
From: Kyle Van Berendonck <<a>kvanberendonck@gmail.com</a>><br>
To: "<a>ghc-devs@haskell.org</a>" <<a>ghc-devs@haskell.org</a>><br>
Subject: Thread status constants<br>
Message-ID:<br>
        <CAFSvR6A3maSWngY=<u></u>GJdATvGPjTAyuPokXZ5=rLtLT=<a>EbYdSLKA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
I found these:<br>
<a href="https://github.com/ghc/ghc/blob/5f3c5384df59717ca8013c5df8d1f65692867825/includes/rts/Constants.h#L194" target="_blank">https://github.com/ghc/ghc/<u></u>blob/<u></u>5f3c5384df59717ca8013c5df8d1f6<u></u>5692867825/includes/rts/<u></u>Constants.h#L194</a><br>

<br>
They go only 0-14, so there's some long chains of branches and stuff in hot<br>
paths that could be cleaned up into single &-masked branches by changing<br>
these into a set of flags.<br>
<br>
And then I saw these:<br>
<a href="https://github.com/ghc/ghc/blob/master/libraries/base/GHC/Conc/Sync.lhs#L483" target="_blank">https://github.com/ghc/ghc/<u></u>blob/master/libraries/base/<u></u>GHC/Conc/Sync.lhs#L483</a><br>
<br>
Where does 16 and 17 come from -- I couldn't find them in the header files<br>
anywhere?<br>
<br>
Kyle<br>
</blockquote>
<br>
Hi Kyle,<br>
<br>
I had a look at these constants just recently.<br>
<br>
About 16 and 17, see here:<br>
  <a href="https://github.com/ghc/ghc/blob/master/rts/PrimOps.cmm#L853" target="_blank">https://github.com/ghc/ghc/<u></u>blob/master/rts/PrimOps.cmm#<u></u>L853</a><br>
<br>
About the others:The block reasons received two updates just recently.<br>
Turns out that the eventlog (GHC's post-mortem tracing for threadscope et al.) expects these states to have particular values (those in includes/rts/Constants.h, consider them a fixed ABI for the time being).<br>
See here for the story:<br>
  <a href="https://ghc.haskell.org/trac/ghc/ticket/9003" target="_blank">https://ghc.haskell.org/trac/<u></u>ghc/ticket/9003</a><br>
<br>
NB: Darn... base still uses GHC-7.8.2 constants. Thanks for the pointer!<br>
<br>
About your proposal to use bit masks:<br>
<br>
Did you find some of those hot paths?<br>
I believe (believe, unchecked...) that there are not too many places where a complete switch over all possible reasons is done (apart from debug output maybe); the typical use is rather to compare to one single constant than to all. So the performance might not increase too much from optimisations. Again, just a hunch, not verified.<br>

<br>
If the RTS contains code specialised to the current constants, these places need to be kept symbolic, to avoid future breakage when new states are added.<br>
<br>
A fix which removes the tight implicit dependency of ghc-events from the constants in includes/rts/Constants.h is pending, btw.<br>
<br>
/ Jost<br>
<br>
______________________________<u></u>_________________<br>
ghc-devs mailing list<br>
<a>ghc-devs@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-devs" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/ghc-devs</a><br>
</blockquote>