Skip to content

Commit e0893a6

Browse files
committed
Improve cache clearing, fix cache statistics, and improve encapsulation
1 parent ef13dc2 commit e0893a6

3 files changed

Lines changed: 163 additions & 110 deletions

File tree

src/doxygen.cpp

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9462,19 +9462,7 @@ static void flushCachedTemplateRelations()
94629462
// as there can be new template instances in the inheritance path
94639463
// to this class. Optimization: only remove those classes that
94649464
// have inheritance instances as direct or indirect sub classes.
9465-
StringVector elementsToRemove;
9466-
for (const auto &ci : SymbolResolver::typeLookupCache())
9467-
{
9468-
const LookupInfo &li = ci.second;
9469-
if (li.definition)
9470-
{
9471-
elementsToRemove.push_back(ci.first);
9472-
}
9473-
}
9474-
for (const auto &k : elementsToRemove)
9475-
{
9476-
SymbolResolver::typeLookupCache().remove(k);
9477-
}
9465+
SymbolResolver::clearTypeLookupCache(SymbolResolver::ClearScope::Classes);
94789466

94799467
// remove all cached typedef resolutions whose target is a
94809468
// template class as this may now be a template instance
@@ -9521,34 +9509,8 @@ static void flushUnresolvedRelations()
95219509
// class A { class I {} };
95229510
// class B : public A {};
95239511
// class C : public B::I {};
9512+
SymbolResolver::clearTypeLookupCache(SymbolResolver::ClearScope::Unresolved);
95249513

9525-
StringVector elementsToRemove;
9526-
for (const auto &ci : SymbolResolver::typeLookupCache())
9527-
{
9528-
const LookupInfo &li = ci.second;
9529-
if (li.definition==nullptr && li.typeDef==nullptr)
9530-
{
9531-
elementsToRemove.push_back(ci.first);
9532-
}
9533-
}
9534-
for (const auto &k : elementsToRemove)
9535-
{
9536-
SymbolResolver::typeLookupCache().remove(k);
9537-
}
9538-
9539-
// for each global function name
9540-
for (const auto &fn : *Doxygen::functionNameLinkedMap)
9541-
{
9542-
// for each function with that name
9543-
for (const auto &ifmd : *fn)
9544-
{
9545-
MemberDefMutable *fmd = toMemberDefMutable(ifmd.get());
9546-
if (fmd)
9547-
{
9548-
fmd->invalidateCachedArgumentTypes();
9549-
}
9550-
}
9551-
}
95529514
// for each class method name
95539515
for (const auto &nm : *Doxygen::memberNameLinkedMap)
95549516
{
@@ -11550,22 +11512,6 @@ void cleanUpDoxygen()
1155011512
delete Doxygen::symbolMap;
1155111513
}
1155211514

11553-
static int computeIdealCacheParam(size_t v)
11554-
{
11555-
//printf("computeIdealCacheParam(v=%u)\n",v);
11556-
11557-
int r=0;
11558-
while (v!=0)
11559-
{
11560-
v >>= 1;
11561-
r++;
11562-
}
11563-
// r = log2(v)
11564-
11565-
// convert to a valid cache size value
11566-
return std::max(0,std::min(r-16,9));
11567-
}
11568-
1156911515
void readConfiguration(int argc, char **argv)
1157011516
{
1157111517
QCString versionString = getFullVersion();
@@ -12838,7 +12784,7 @@ void parseInput()
1283812784
// calling buildClassList may result in cached relations that
1283912785
// become invalid after resolveClassNestingRelations(), that's why
1284012786
// we need to clear the cache here
12841-
SymbolResolver::typeLookupCache().clear();
12787+
SymbolResolver::clearTypeLookupCache(SymbolResolver::ClearScope::All);
1284212788
// we don't need the list of using declaration anymore
1284312789
g_usingDeclarations.clear();
1284412790

@@ -13478,16 +13424,7 @@ void generateOutput()
1347813424
g_outputList->cleanup();
1347913425
cleanupInlineGraph();
1348013426

13481-
msg("type lookup cache used {}/{} hits={} misses={}\n",
13482-
SymbolResolver::typeLookupCache().size(),
13483-
SymbolResolver::typeLookupCache().capacity(),
13484-
SymbolResolver::typeLookupCache().hits(),
13485-
SymbolResolver::typeLookupCache().misses());
13486-
int cacheParam = computeIdealCacheParam(static_cast<size_t>(SymbolResolver::typeLookupCache().misses()*2/3)); // part of the cache is flushed, hence the 2/3 correction factor
13487-
if (cacheParam>Config_getInt(LOOKUP_CACHE_SIZE))
13488-
{
13489-
msg("Note: based on cache misses the ideal setting for LOOKUP_CACHE_SIZE is {} at the cost of higher memory usage.\n",cacheParam);
13490-
}
13427+
SymbolResolver::showCacheUsage();
1349113428

1349213429
if (Debug::isFlagSet(Debug::Time))
1349313430
{

0 commit comments

Comments
 (0)