[GHC] #11486: info tables are no longer aligned

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Take a simple program like {{{ main = mapM_ print "Hello, world" }}} and build with `-O`. Versions of ghc as late as 7.11.20150806 generate assembly that includes {{{ ... _c3mn: movq $sat_s3m2_info,-16(%r12) movq %r14,(%r12) movq $block_c3mi_info,-16(%rbp) movl $GHC.Types.True_closure+2,%edi movq %rsi,%rax leaq -16(%r12),%rsi movl $GHC.IO.Handle.FD.stdout_closure,%r14d movq %rax,-8(%rbp) addq $-16,%rbp jmp GHC.IO.Handle.Text.hPutStr2_info .text .align 8 .quad 1 .quad 32 block_c3mi_info: _c3mi: movq 8(%rbp),%rbx addq $16,%rbp jmp stg_ap_v_fast ... }}} Note the `.align 8` ensuring that the info table (and the code `_c3mi` itself) is 8-byte aligned. In 8.1.20160107 we instead get {{{ _c5gE: movq $sat_s5g9_info,-16(%r12) movq %r14,(%r12) movq $block_c5gz_info,-16(%rbp) movl $GHC.Types.True_closure+2,%edi movq %rsi,%rax leaq -16(%r12),%rsi movl $GHC.IO.Handle.FD.stdout_closure,%r14d movq %rax,-8(%rbp) addq $-16,%rbp jmp GHC.IO.Handle.Text.hPutStr2_info _c5gF: movq $24,904(%r13) _c5gC: movl $Main.main2_closure,%ebx jmp *-8(%r13) .quad 1 .quad 32 block_c5gz_info: _c5gz: movq 8(%rbp),%rbx addq $16,%rbp jmp stg_ap_v_fast .size Main.main2_info, .-Main.main2_info }}} There is some minor rearrangement, but more importantly there is no longer any `.align 8` before `.quad 1`. That means the info table is not necessarily aligned, and indeed `c5gz_info` ended up at the address `40676f`. I'm guessing this is bad for performance, though I don't know how bad. I'm pretty sure this is due to 4a32bf925b8aba7885d9c745769fe84a10979a53 "Implement function-sections for Haskell code" though I haven't looked at that commit in detail. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: simonmar (added) Comment: Simon O, Simon M, it'd b good to nail this. Looks bad to me. Well spotted Reid. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I suspect the issue here is the `pprSectionHeader` removed from `pprBasicBlock`. {{{#!patch @@ -113,7 +109,6 @@ pprBasicBlock info_env (BasicBlock blockid instrs) maybe_infotable = case mapLookup blockid info_env of Nothing -> empty Just (Statics info_lbl info) -> - pprSectionHeader Text $$ infoTableLoc $$ vcat (map pprData info) $$ pprLabel info_lbl }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1846 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D1846 Comment: Possibly fixed in Phab:D1846. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1847 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * differential: Phab:D1846 => Phab:D1847 Comment: More thorough fix in Phab:D1847. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: patch
Priority: high | Milestone: 8.0.1
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1847
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1847 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1847 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged as 7a70f980d39533f30e1a6504b7821e63a4d6f41e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11486: info tables are no longer aligned -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1847 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): This had a small, but mostly beneficial effect on performance: https://perf.haskell.org/ghc/#revision/0dc7b36c3c261b3eccf8460581fcd3d71f6e6... As expected, there is a code size cost, which has an indirect performance cost as well (since density of real code in the instruction cache is lower). Not exactly germane to this ticket, but perhaps it would be worth experimenting with half-word-aligned info tables? Many of the info table fields are half-word-sized anyways. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11486#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC