Reset resolver probe counters per query window

This commit is contained in:
2026-06-20 22:12:40 -05:00
parent da92e927e5
commit 7a7b18d449
+11 -3
View File
@@ -278,6 +278,7 @@ uint32_t gGpsCostTablePatchLogCount = 0;
uint32_t gGpsProviderClassPatchLogCount = 0; uint32_t gGpsProviderClassPatchLogCount = 0;
std::array<uint32_t, 4> gGpsResolveHandleRetLogCounts{}; std::array<uint32_t, 4> gGpsResolveHandleRetLogCounts{};
uint64_t gGpsResolveTraceWindowUntilMs = 0; uint64_t gGpsResolveTraceWindowUntilMs = 0;
uint32_t gGpsResolveTraceWindowSerial = 0;
std::array<uint32_t, 64> gGpsEdgeCostClassLogCounts{}; std::array<uint32_t, 64> gGpsEdgeCostClassLogCounts{};
std::mutex gGpsCostLogMutex; std::mutex gGpsCostLogMutex;
std::mutex gGpsAsyncLogMutex; std::mutex gGpsAsyncLogMutex;
@@ -1111,6 +1112,8 @@ void ExtendGpsResolveTraceWindow(uint64_t aNowMs)
{ {
std::lock_guard lock(gGpsCostLogMutex); std::lock_guard lock(gGpsCostLogMutex);
const auto untilMs = aNowMs + kGpsResolveTraceWindowMs; const auto untilMs = aNowMs + kGpsResolveTraceWindowMs;
std::fill(gGpsResolveHandleRetLogCounts.begin(), gGpsResolveHandleRetLogCounts.end(), 0);
++gGpsResolveTraceWindowSerial;
if (untilMs > gGpsResolveTraceWindowUntilMs) if (untilMs > gGpsResolveTraceWindowUntilMs)
{ {
gGpsResolveTraceWindowUntilMs = untilMs; gGpsResolveTraceWindowUntilMs = untilMs;
@@ -4000,16 +4003,19 @@ int32_t DetourGpsResolveHandle(void* aGraph, uint64_t aHandle, void* aOutSegment
const auto pointIndex = aHandle & 0xFFFFF; const auto pointIndex = aHandle & 0xFFFFF;
uint32_t callCount = 0; uint32_t callCount = 0;
uint32_t returnCallCount = 0; uint32_t returnCallCount = 0;
uint32_t traceWindowSerial = 0;
bool inTraceWindow = false;
bool shouldLog = false; bool shouldLog = false;
{ {
std::lock_guard lock(gGpsCostLogMutex); std::lock_guard lock(gGpsCostLogMutex);
callCount = gGpsResolveHandleLogCount++; callCount = gGpsResolveHandleLogCount++;
const auto returnBucket = GetGpsResolveReturnBucket(returnRva); const auto returnBucket = GetGpsResolveReturnBucket(returnRva);
if (returnBucket < gGpsResolveHandleRetLogCounts.size()) inTraceWindow = GetElapsedMs() <= gGpsResolveTraceWindowUntilMs;
traceWindowSerial = gGpsResolveTraceWindowSerial;
if (inTraceWindow && returnBucket < gGpsResolveHandleRetLogCounts.size())
{ {
returnCallCount = gGpsResolveHandleRetLogCounts[returnBucket]++; returnCallCount = gGpsResolveHandleRetLogCounts[returnBucket]++;
} }
const auto inTraceWindow = GetElapsedMs() <= gGpsResolveTraceWindowUntilMs;
shouldLog = result >= 0 && hasSegment && hasPoint && shouldLog = result >= 0 && hasSegment && hasPoint &&
((IsSelectedGpsResolveReturnRva(returnRva) && inTraceWindow && ((IsSelectedGpsResolveReturnRva(returnRva) && inTraceWindow &&
returnCallCount < kGpsResolveSelectedRetLogLimit) || returnCallCount < kGpsResolveSelectedRetLogLimit) ||
@@ -4031,6 +4037,7 @@ int32_t DetourGpsResolveHandle(void* aGraph, uint64_t aHandle, void* aOutSegment
std::ostringstream line; std::ostringstream line;
line << "hook GPSResolveHandle 0x44e1a8 call=" << callCount << " retCall=" << returnCallCount line << "hook GPSResolveHandle 0x44e1a8 call=" << callCount << " retCall=" << returnCallCount
<< " traceWindow=" << traceWindowSerial << " inTraceWindow=" << (inTraceWindow ? 1 : 0)
<< " value=0x" << std::hex << static_cast<uint32_t>(result) << " handle=0x" << aHandle << std::dec; << " value=0x" << std::hex << static_cast<uint32_t>(result) << " handle=0x" << aHandle << std::dec;
AppendGpsPackedHandleSummary(line, "handle", aHandle); AppendGpsPackedHandleSummary(line, "handle", aHandle);
AppendPointerWithRva(line, "graph", aGraph); AppendPointerWithRva(line, "graph", aGraph);
@@ -4047,7 +4054,8 @@ int32_t DetourGpsResolveHandle(void* aGraph, uint64_t aHandle, void* aOutSegment
AppendPointerWithRva(line, "segment_p38", aux38); AppendPointerWithRva(line, "segment_p38", aux38);
AppendGpsPointSummary(line, "pointSummary", point); AppendGpsPointSummary(line, "pointSummary", point);
const auto shouldDumpBytes = const auto shouldDumpBytes =
callCount < kGpsResolveVerboseDumpLimit || returnCallCount < kGpsResolveVerboseDumpLimit; callCount < kGpsResolveVerboseDumpLimit ||
(inTraceWindow && returnCallCount < kGpsResolveVerboseDumpLimit);
line << " dump=" << (shouldDumpBytes ? 1 : 0); line << " dump=" << (shouldDumpBytes ? 1 : 0);
if (shouldDumpBytes) if (shouldDumpBytes)
{ {