The size of each CAF could be reduced by moving the code that allocates the blackhole indirection closure out from the CAF's closure body and into newCAF. This saves around 50 bytes of object code per CAF.
Trac metadata
Trac field
Value
Version
7.7
Type
FeatureRequest
TypeOfFailure
OtherFailure
Priority
normal
Resolution
Unresolved
Component
Compiler (NCG)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Runtime results are mixed (likely noise I think)
Allocation doesn't change except with cacheprof which sees an increase of 0.6%..
Binary size changes between -3.5% to -1.3%
Compile-time allocation changes between -10.3% to 0%
Yes, this is a good plan. I think I considered it before but I was worried about the cost of allocate vs. inline allocation in the CAF code, but I think a 2% reduction in code size is worth far more, and CAF entry is a one-time cost. So go ahead!
Looks great to me. Could you bear to write a Note [How CAFs are compiled] in StgCmmBind (and perhaps cross-refer from Storage.c) so that there is a little writeup of the logic involved. Or maybe the Note belongs somewhere else. It would be good to cover (briefly)
Simon, this is pretty well documented already in Storage.c, all the points you mention are already covered. In fact some of it is *also* documented in StgCmmBind. I suggest:
remove the comments in StgCmmBind, replace with a pointer to Storage.c. Multiple comments describing the same thing are bad, because when making changes we'll tend to only update one of them.
edit the comments in Storage.c to bring them up to date with the changes.
Great! Sorry I was just looking at the patch itself.
Indeed a pointer from (the appropriate point in) StgCmmBind to the detailed description in Storage.c would be good. Also from the wiki page I referenced.
Thanks for the comments. I've deduplicated and updated the CAF documentation in a followup patch.
In the meantime, I noticed an oversight in the original patch. lockCAF() was not setting the profiling header of the newly-allocated blackhole. To fix this, I changed the following line
I am attempting to further reduce the code size of CAFs by moving the CAF-updating code out from each CAF and into a shared "CAF" info-table. For example, consider the module
moduleCAFwherea="test"
Currently, the Cmm outputted for this module looks like
Each CAF is augmented with code that handles the updating of the CAF itself. This is the newCAF() stuff shown above. It should be possible to refactor the CAF-updating out of the entry code of a CAF and into a special "CAF" info table. For example, the above code could look like
[section"data"{CAF.a_closure:conststg_CAF_info;// XXX new info tableconst0;const0;constCAF.a_info;// pointer to the "real" info table// this field corresponds to the saved_info field of an StgIndstatic},section"readonly"{cCK_str:I8[][116,101,115,116]},CAF.a_entry()// [R1]{info_tbl:[(cCL,label:CAF.a_inforep:HeapRepstatic{Thunk})]stack_info:arg_space:8updfr_space:Just8}{offsetcCL:// no CAF boilerplate here!R2=cCK_str;callGHC.CString.unpackCString#_info(R2)args:8,res:0,upd:8;}}]
where stg_CAF_info is the info table that encapsulates the CAF-specific code:
Firstly, I wonder whether this approach is feasible. Is there a reason why CAF updates are not implemented this way in the first place?
I have a tentative patch that implements this approach, and it does produce correct results given contrived input -- but when I try bootstrap GHC with the patch, the dll-split program (which is built against ghc-stage1) segfaults. So there is strong reason to believe that there is something flawed about the idea and/or the implementation.
My STG-fu is still weak, and I am failing to figure out the source of the problem. dll-split does not have any CAFs Does anybody have any insights on
Does anyone have any insights on this approach of updating CAFs and on what may be causing the segfault?