OSDN Git Service

[ADT] Make the triple test 1000x faster through more focused test cases.
authorChandler Carruth <chandlerc@gmail.com>
Sat, 6 Aug 2016 06:00:50 +0000 (06:00 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 6 Aug 2016 06:00:50 +0000 (06:00 +0000)
commit8682b372bb5e865d33a79bcba4f5e89ec4f1b1ac
treee6db5390fefbe219be6d9b708a10024a018374df
parent9da24c7e7fa3b2dad30556b45b6e43d3b6121f9c
[ADT] Make the triple test 1000x faster through more focused test cases.

The current approach isn't a long-term viable pattern. Given the set of
architectures A, vendors V, operating systems O, and environments E, it
does |A| * |V| * |O| * |E| * 4! tests. As LLVM grows, this test keeps
getting slower, despite my working very hard to make it get some
"optimizations" even in -O0 builds in order to lower the constant
factors. Fundamentally, we're doing an unreasonable amount of work.i

Looking at the specific thing being tested -- the goal seems very
clearly to be testing the *permutations*, not the *combinations*. The
combinations are driving up the complexity much more than anything else.

Instead, test every possible value for a given triple entry in every
permutation of *some* triple. This really seems to cover the core goal
of the test. Every single possible triple component is tested in every
position. But because we keep the rest of the triple constant, it does
so in a dramatically more scalable amount of time. With this model we do
(|A| + |V| + |O| + |E|) * 4! tests.

For me on a debug build, this goes from running for 19 seconds to 19
milliseconds, or a 1000x improvement. This makes a world of difference
for the critical path of 'ninja check-llvm' and other extremely common
workflows.

Thanks to Renato, Dean, and David for the helpful review comments and
helping me refine the explanation of the change.

Differential Revision: https://reviews.llvm.org/D23156

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277912 91177308-0d34-0410-b5e6-96231b3b80d8
unittests/ADT/TripleTest.cpp