This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Relation slabs should not be accounted when computing backing storage size
ClosedPublic

Authored by ilya-golovenko on Dec 2 2020, 7:08 AM.

Diff Detail

Event Timeline

ilya-golovenko created this revision.Dec 2 2020, 7:08 AM
ilya-golovenko requested review of this revision.Dec 2 2020, 7:08 AM
ilya-golovenko retitled this revision from [clangd] Relations should not be accounted when computing backing storage size to [clangd] Relation slabs should not be accounted when computing backing storage size.Dec 2 2020, 7:11 AM
ilya-golovenko added reviewers: kadircet, sammccall.

Can you give a little context? Why not?

ilya-golovenko added a comment.EditedDec 3 2020, 4:33 AM

Can you give a little context? Why not?

It seems Relations should be not taken into account because they don't reference a backing storage.
Only SymStorage and RefsStorage are passed to the respective index in the Payload argument.

return std::make_unique<MemIndex>(
    llvm::make_pointee_range(AllSymbols), std::move(AllRefs),
    std::move(AllRelations),
    std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs),  <<<<
                    std::move(RefsStorage), std::move(SymsStorage)), <<<<
    StorageSize);

Also, there is a comment regarding Rels slab in Dex.cpp:

std::unique_ptr<SymbolIndex> Dex::build(SymbolSlab Symbols, RefSlab Refs, RelationSlab Rels) {
  auto Size = Symbols.bytes() + Refs.bytes();
  // There is no need to include "Rels" in Data because the relations are self-  <<<<<
  // contained, without references into a backing store.                         <<<<<
  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
  return std::make_unique<Dex>(Data.first, Data.second, Rels, std::move(Data),
                                Size);
}

MemIndex also uses only Symbols and Refs slabs to compute backing storage size.

sammccall accepted this revision.Dec 3 2020, 5:18 AM

Thanks, you're right. There's no "payload" memory here, and MemIndex::estimateMemoryUsage should already be accounting for all the memory used.

(Sorry, it's been a while since I looked at this code)

This revision is now accepted and ready to land.Dec 3 2020, 5:18 AM

Thanks, you're right. There's no "payload" memory here, and MemIndex::estimateMemoryUsage should already be accounting for all the memory used.

(Sorry, it's been a while since I looked at this code)

Thank you for review!