[PATCH] D54622: [clangd] Truncate SymbolID to 8 bytes.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 16 02:47:13 PST 2018
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.
This is our goal. It has a non-zero rick, but so far we haven't see any
collision (externally and internally).
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D54622
Files:
clangd/index/Index.h
clangd/index/Serialization.cpp
unittests/clangd/SerializationTests.cpp
Index: unittests/clangd/SerializationTests.cpp
===================================================================
--- unittests/clangd/SerializationTests.cpp
+++ unittests/clangd/SerializationTests.cpp
@@ -27,7 +27,7 @@
const char *YAML = R"(
---
!Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
Name: 'Foo1'
Scope: 'clang::'
SymInfo:
@@ -53,7 +53,7 @@
...
---
!Symbol
-ID: 057557CEBF6E6B2DD437FBF60CC58F36
+ID: 057557CEBF6E6B2E
Name: 'Foo2'
Scope: 'clang::'
SymInfo:
@@ -72,7 +72,7 @@
CompletionSnippetSuffix: '-snippet'
...
!Refs
-ID: 057557CEBF6E6B2DD437FBF60CC58F35
+ID: 057557CEBF6E6B2D
References:
- Kind: 4
Location:
@@ -99,13 +99,13 @@
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 @@
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);
Index: clangd/index/Serialization.cpp
===================================================================
--- clangd/index/Serialization.cpp
+++ clangd/index/Serialization.cpp
@@ -300,7 +300,7 @@
// 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 @@
// 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);
Index: clangd/index/Index.h
===================================================================
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -116,8 +116,7 @@
// 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54622.174346.patch
Type: text/x-patch
Size: 3322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181116/e863e41f/attachment-0001.bin>
More information about the cfe-commits
mailing list