[clang-tools-extra] r347044 - [clangd] Truncate SymbolID to 8 bytes.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 16 02:58:40 PST 2018
Author: hokein
Date: Fri Nov 16 02:58:40 2018
New Revision: 347044
URL: http://llvm.org/viewvc/llvm-project?rev=347044&view=rev
Log:
[clangd] Truncate SymbolID to 8 bytes.
Summary:
This is our goal. It has a non-zero rick, but so far we haven't see any
collision (externally and internally).
Reviewers: sammccall
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D54622
Modified:
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/Serialization.cpp
clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=347044&r1=347043&r2=347044&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Fri Nov 16 02:58:40 2018
@@ -116,8 +116,7 @@ public:
// The stored hash is truncated to RawSize bytes.
// This trades off memory against the number of symbols we can handle.
- // FIXME: can we reduce this further to 8 bytes?
- constexpr static size_t RawSize = 16;
+ constexpr static size_t RawSize = 8;
llvm::StringRef raw() const {
return StringRef(reinterpret_cast<const char *>(HashValue.data()), RawSize);
}
Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=347044&r1=347043&r2=347044&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Fri Nov 16 02:58:40 2018
@@ -300,7 +300,7 @@ Symbol readSymbol(Reader &Data, ArrayRef
// REFS ENCODING
// A refs section has data grouped by Symbol. Each symbol has:
-// - SymbolID: 16 bytes
+// - SymbolID: 8 bytes
// - NumRefs: varint
// - Ref[NumRefs]
// Fields of Ref are encoded in turn, see implementation.
@@ -338,7 +338,7 @@ std::pair<SymbolID, std::vector<Ref>> re
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 6;
+constexpr static uint32_t Version = 7;
Expected<IndexFileIn> readRIFF(StringRef Data) {
auto RIFF = riff::readFile(Data);
Modified: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp?rev=347044&r1=347043&r2=347044&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp Fri Nov 16 02:58:40 2018
@@ -27,7 +27,7 @@ namespace {
const char *YAML = R"(
---
!Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
Name: 'Foo1'
Scope: 'clang::'
SymInfo:
@@ -53,7 +53,7 @@ IncludeHeaders:
...
---
!Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
Name: 'Foo2'
Scope: 'clang::'
SymInfo:
@@ -72,7 +72,7 @@ Signature: '-sig'
CompletionSnippetSuffix: '-snippet'
...
!Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
References:
- Kind: 4
Location:
@@ -99,13 +99,13 @@ TEST(SerializationTest, YAMLConversions)
ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError();
ASSERT_TRUE(bool(ParsedYAML->Symbols));
EXPECT_THAT(*ParsedYAML->Symbols,
- UnorderedElementsAre(ID("057557CEBF6E6B2DD437FBF60CC58F35"),
- ID("057557CEBF6E6B2DD437FBF60CC58F36")));
+ UnorderedElementsAre(ID("057557CEBF6E6B2D"),
+ ID("057557CEBF6E6B2E")));
auto Sym1 = *ParsedYAML->Symbols->find(
- cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")));
+ cantFail(SymbolID::fromStr("057557CEBF6E6B2D")));
auto Sym2 = *ParsedYAML->Symbols->find(
- cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F36")));
+ cantFail(SymbolID::fromStr("057557CEBF6E6B2E")));
EXPECT_THAT(Sym1, QName("clang::Foo1"));
EXPECT_EQ(Sym1.Signature, "");
@@ -131,7 +131,7 @@ TEST(SerializationTest, YAMLConversions)
EXPECT_THAT(
*ParsedYAML->Refs,
UnorderedElementsAre(
- Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2DD437FBF60CC58F35")),
+ Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")),
testing::SizeIs(1))));
auto Ref1 = ParsedYAML->Refs->begin()->second.front();
EXPECT_EQ(Ref1.Kind, RefKind::Reference);
More information about the cfe-commits
mailing list