1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/unittests/Support
Graydon Hoare cded1d3751 [Support] Make line-number cache robust against access patterns.
Summary:
The LLVM SourceMgr class (which is used indirectly by Swift, though not Clang)
has a routine for looking up line numbers of SMLocs. This routine uses a
shared, special-purpose cache that handles exactly one access pattern
efficiently: looking up the line number of an SMLoc that points into the same
buffer as the last query made to the SourceMgr, at a location in the buffer at
or ahead of the last query.

When this works it's fine, but when it fails it's catastrophic for performancer:
one recent out-of-order access from a Swift utility routine ran for tens of
seconds, spending 99% of its time repeatedly scanning buffers for '\n'.

This change removes the shared cache from the SourceMgr and installs a new
cache in each SrcBuffer. The per-SrcBuffer caches are also "full", in the sense
that rather than caching a single last-query pointer, they cache _all_ the
line-ending offsets, in a binary-searchable array, such that once it's
populated (on first access), all subsequent access patterns run at the same
speed.

Performance measurements I've done show this is actually a little bit faster on
real codebases (though only a couple fractions of a percent). Memory usage is
up by a few tens to hundreds of bytes per SrcBuffer that has a line lookup done
on it; I've attempted to minimize this by using dynamic selection of integer
sized when storing offset arrays. But the main motive here is to
make-impossible the cases we don't always see, that show up by surprise when
there is an out-of-order access pattern.

Reviewers: jordan_rose

Reviewed By: jordan_rose

Subscribers: probinson, llvm-commits

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

llvm-svn: 329470
2018-04-07 00:44:02 +00:00
..
DynamicLibrary [CMake] Use PRIVATE in target_link_libraries for executables 2017-12-05 21:49:56 +00:00
AlignOfTest.cpp Revert r291503, "Lift the 10-type limit for AlignedCharArrayUnion", and followings. 2017-01-13 01:13:10 +00:00
AllocatorTest.cpp Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
ARMAttributeParser.cpp Remove redundant includes from unittests. 2017-12-13 21:31:05 +00:00
ArrayRecyclerTest.cpp
BinaryStreamTest.cpp Remove redundant includes from unittests. 2017-12-13 21:31:05 +00:00
BlockFrequencyTest.cpp
BranchProbabilityTest.cpp [BPI] Add multiplication by scalar operators to BranchProbability 2017-04-21 03:14:30 +00:00
CachePruningTest.cpp Unbreak the build. Combining chrono with Optional is annoying. 2017-12-22 21:18:50 +00:00
Casting.cpp [Support] Add support for unique_ptr<> to Casting.h. 2017-04-12 19:59:37 +00:00
CheckedArithmeticTest.cpp Utility functions for checked arithmetic 2018-03-02 00:30:43 +00:00
Chrono.cpp Support formatv of TimePoint with strftime-style formats. 2017-10-24 08:30:19 +00:00
CMakeLists.txt Utility functions for checked arithmetic 2018-03-02 00:30:43 +00:00
CommandLineTest.cpp On Windows we need to be able to process response files with Windows-style 2018-03-05 19:34:33 +00:00
CompressionTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
ConvertUTFTest.cpp Remove redundant includes from unittests. 2017-12-13 21:31:05 +00:00
CrashRecoveryTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
DataExtractorTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
DebugTest.cpp Fix unit test in NDEBUG build 2016-12-27 11:07:53 +00:00
DJBTest.cpp Resubmit r325107 (case folding DJB hash) 2018-02-21 22:36:31 +00:00
EndianStreamTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
EndianTest.cpp
ErrnoTest.cpp Recommit "[Support] Add RetryAfterSignal helper function" 2017-06-29 13:15:31 +00:00
ErrorOrTest.cpp Fix incorrect usage of std::is_assignable. 2018-02-02 22:29:54 +00:00
ErrorTest.cpp [Testing/Support]: Better matching of Error failure states 2018-04-05 14:32:10 +00:00
FileOutputBufferTest.cpp Convert FileOutputBuffer::commit to Error. 2017-11-08 01:50:29 +00:00
formatted_raw_ostream_test.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
FormatVariadicTest.cpp Fix FormatVariadicTest with GCC 2017-10-23 18:41:22 +00:00
GlobPatternTest.cpp [Support/GlobPattern] - Do not crash when pattern has characters with int value < 0. 2017-07-31 09:26:50 +00:00
Host.cpp [AArch64] Add Exynos to host detection 2017-12-08 21:09:59 +00:00
LEB128Test.cpp Change encodeU/SLEB128 to pad to certain number of bytes 2017-09-15 20:34:47 +00:00
LineIteratorTest.cpp
LockFileManagerTest.cpp
ManagedStatic.cpp Report fatal error in the case of out of memory 2018-02-20 05:41:26 +00:00
MathExtrasTest.cpp MathExtras UnitTest: Assert that isPowerOf2(0) is false. NFC. 2017-07-03 18:42:47 +00:00
MD5Test.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
MemoryBufferTest.cpp [Support] Pacify -Wsign-compare in unit test. 2018-03-08 21:54:30 +00:00
MemoryTest.cpp Untabify. 2017-10-18 13:31:28 +00:00
NativeFormatTests.cpp [Support] Introduce llvm::formatv() function. 2016-11-11 23:57:40 +00:00
ParallelTest.cpp SupportTests: Suppress ParallelTests on mingw for now. Investigating. 2017-05-11 06:35:51 +00:00
Path.cpp [llvm-cov] Prevent llvm-cov from hanging when a symblink doesn't exist. 2018-04-05 19:43:24 +00:00
ProcessTest.cpp [Support] env vars with empty values on windows 2017-08-18 16:55:44 +00:00
ProgramTest.cpp Convenience/safety fix for llvm::sys::Execute(And|No)Wait 2017-09-13 17:03:37 +00:00
raw_ostream_test.cpp Support: Add llvm::center_justify. 2017-07-13 16:11:08 +00:00
raw_pwrite_stream_test.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
raw_sha1_ostream_test.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
RegexTest.cpp Fix llvm-special-case-list-fuzzer regexp exception 2017-10-27 19:15:13 +00:00
ReplaceFileTest.cpp Support: Rewrite Windows implementation of sys::fs::rename to be more POSIXy. 2017-10-06 17:14:36 +00:00
ReverseIterationTest.cpp [unittest/ReverseIteration] Unbreak when compiling with GCC. 2017-09-05 21:27:23 +00:00
ScaledNumberTest.cpp Cosmetic. Added braces to address gcc warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]. 2017-05-20 00:02:08 +00:00
SourceMgrTest.cpp [Support] Make line-number cache robust against access patterns. 2018-04-07 00:44:02 +00:00
SpecialCaseListTest.cpp Extend SpecialCaseList to allow users to blame matches on entries in the file. 2017-11-07 21:16:46 +00:00
StringPool.cpp
SwapByteOrderTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
TargetParserTest.cpp Fix signed/unsigned compare warning I introduced 2018-02-08 17:11:32 +00:00
TarWriterTest.cpp Fix build bot after r319750 "[Support/TarWriter] - Don't allow TarWriter to add the same file more than once." 2017-12-05 10:35:11 +00:00
Threading.cpp Rename interface for querying physical hardware concurrency 2016-10-17 14:56:53 +00:00
ThreadLocalTest.cpp
ThreadPool.cpp Remove unused lambda captures. NFC 2017-01-13 17:12:16 +00:00
TimerTest.cpp Timer: Track name and description. 2016-11-18 19:43:18 +00:00
TrailingObjectsTest.cpp Workaround MSVC bug when using TrailingObjects from a template. 2017-02-28 18:05:41 +00:00
TrigramIndexTest.cpp Re-sort #include lines for unittests. This uses a slightly modified 2017-06-06 11:06:56 +00:00
TypeNameTest.cpp
UnicodeTest.cpp
xxhashTest.cpp Add xxhash to llvm. 2016-09-27 15:45:57 +00:00
YAMLIOTest.cpp [YAML] Remove unit test of multibyte non-printable escaping that uses C++11 escapes 2018-03-27 20:46:26 +00:00
YAMLParserTest.cpp [YAMLParser] Don't crash on null keys in KeyValueNodes. 2017-11-23 20:57:20 +00:00