Opened 16 months ago

Last modified 9 months ago

#15148 new task

Allow setting of custom alignments

Reported by: AndreasK Owned by:
Priority: normal Milestone: 8.10.1
Component: Compiler (NCG) Version: 8.2.2
Keywords: CodeGen Cc: jmct
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #15124 Differential Rev(s): Phab:D4706
Wiki Page:

Description

Alignment can introduce a bias to benchmarking results which isn't obvious. To help deal with that I want to add some options adjusting alignment for generated code.

To give one example I came across while looking into #15124:

Padding a function that is not even called in nofib/real/eff/FS by multiples of 8 bytes gave runtimes of ~240ms, ~220ms and ~210ms depending on the padding. At 64 byte it seems to loop around (size of a cache line).

At a minimum it should be possible to specify alignment of functions.

Potentially we could also consider:

  • Padding for sections.
  • Padding for functions
  • Alignment for info tables.
  • Padding for info tables.
  • Alignment for Data

The cases where this could have benefits:


Problem: We optimize one subroutine changing it's size. This leads to alignment changes for the following functions making overall performance potentially worse.

Here aligning functions along cache lines would make benchmarks more resilient against accidental alignment changes.


Problem: We might try to optimize code based on a specific benchmark. Going purely by performance of this benchmark we might end up optimizing our code for this specific benchmark instead of the general case.

Varying the alignment would to check if our code simply found a optimum for the alignment caused by this benchmark or if it is generally better.

Change History (4)

comment:1 Changed 16 months ago by Ben Gamari <ben@…>

In f68c2cb/ghc:

Allow aligning of cmm procs at specific boundry

Allows to align CmmProcs at the given boundries.

It makes performance usually worse but can be helpful
to limit the effect of a unrelated function B becoming
faster/slower after changing function A.

Test Plan: ci, using it.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15148

Differential Revision: https://phabricator.haskell.org/D4706

comment:2 Changed 15 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be addressed for GHC 8.6.

comment:3 Changed 14 months ago by AndreasK

Differential Rev(s): Phab:D4706

comment:4 Changed 9 months ago by osa1

Milestone: 8.8.18.10.1

Bumping milestones of low-priority tickets.

Note: See TracTickets for help on using tickets.