Skip to content

Commit f02e788

Browse files
committed
[docs] Expand discussion of easier forms of bisection and reduction.
1 parent 39ff8ae commit f02e788

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

docs/CompilerPerformance.md

+40-8
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,46 @@ getting slower between versions:
894894
study. If the problem is _blindingly obvious_ at this point, stop and fix
895895
the bug, otherwise proceed to narrowing the problem.
896896
897-
8. Reduce the testcase. You can do this manually by deleting chunks of it and
898-
re-checking to see if the problem persists, or you can use `creduce` in
899-
conjunction with `perf`, which will mechanically reduce it. See the section
900-
on `creduce` for details.
901-
902-
9. Bisect the regression range. You can do this manually by trial and error,
903-
or by downloading pre-built snapshot compilers from swift.org, or with the
904-
assistance of `git bisect`, which can semi-automate or totally-automate the
897+
8. Reduce the testcase. That is, figure out the smallest input file that
898+
causes the regression you're observing. If the problem you're looking at
899+
occurs in the frontend, you might be able to do this manually by running
900+
the input with `-Xfrontend -debug-time-function-bodies` and deleting all
901+
but the most expensive function, or reduce even further from a function to
902+
a single expression via `-Xfrontend -debug-time-expression-type-checking`;
903+
but keep in mind these options only track the time spent _typechecking_ a
904+
given function or expression; they do not help in reduction of testcases
905+
for problems that occur in other subsystems of the compiler. For general
906+
reduction, the normal approach is "bisection", also called
907+
"delta-debugging": repeatedly delete half the remaining contents of the
908+
file, and see if the regression remains. If so, repeat the process in the
909+
remaining half; if not, restore the half you deleted and switch your
910+
attention to it. This process -- along with several other reduction
911+
heuristics that are sensitive to the structure of the code -- can also be
912+
automated with the tool `creduce`. See the section on `creduce` for
913+
details.
914+
915+
9. Bisect the regression range. That is, figure out the smallest range of
916+
changes to the compiler (typically a single revision in the git history)
917+
that caused the regression. If you have more network bandwidth than compute
918+
power available, you might want to begin this part by downloading snapshots
919+
of the compiler from swift.org. While only a handful of recent snapshots
920+
are linked on the swift.org webpage, all historical snapshots remain
921+
available to download by substituting the appropriate timestamp into the
922+
snapshot URL. For example, the master-branch, macOS snapshot from June 9
923+
2017 is available
924+
at
925+
[https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-06-09-a/swift-DEVELOPMENT-SNAPSHOT-2017-06-09-a-osx.pkg](https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2017-06-09-a/swift-DEVELOPMENT-SNAPSHOT-2017-06-09-a-osx.pkg),
926+
and the July 10 2017, swift-4.0-branch Linux snapshot is
927+
at
928+
[https://swift.org/builds/swift-4.0-branch/ubuntu1604/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a-ubuntu16.04.tar.gz](https://swift.org/builds/swift-4.0-branch/ubuntu1604/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a/swift-4.0-DEVELOPMENT-SNAPSHOT-2017-07-10-a-ubuntu16.04.tar.gz).
929+
While such snapshots have asserts enabled -- so they do not entirely match
930+
the performance characteristics of release compilers -- it is often the
931+
case that a regression in a release compiler will still show up in an
932+
assert compiler, and downloading snapshots to narrow a regression range can
933+
often be much faster than building multiple compilers. Once you've narrowed
934+
a regression range to within a few days (or however far you can get with
935+
snapshots alone), you will likely also need to switch to bisection using
936+
`git bisect`, which can semi-automate or totally-automate the remaining
905937
search, depending on how much shell scripting you want to do and how
906938
precisely you're able to measure the difference. See the section on
907939
`git-bisect` for details.

0 commit comments

Comments
 (0)