[idd] logging: make periodic statistics opt-in

This commit is contained in:
Geoffrey McRae
2026-08-14 02:47:56 +10:00
parent 879b8429e7
commit caf8515e9d
8 changed files with 78 additions and 54 deletions

View File

@@ -20,6 +20,7 @@
#include "capture/CFrameScheduler.h"
#include "config/CSettings.h"
#include "CDebug.h"
#include "Seq.h"
@@ -992,6 +993,9 @@ void CFrameScheduler::LogStatistics(uint64_t now)
m_lastLogPublished = m_publishedFrames;
lock.Unlock();
if (!g_settings.ShouldLogStatistics())
return;
const double acquiredRate =
static_cast<double>(acquired) * 1000000000.0 / elapsed;
DEBUG_TRACE("Frame schedule owner %u: %.3f Hz client, %.3f Hz acquired, "

View File

@@ -27,8 +27,6 @@
CSettings g_settings;
#define LGIDD_REGKEY L"SOFTWARE\\LookingGlass\\IDD"
CSettings::CSettings()
{
}
@@ -107,7 +105,7 @@ bool CSettings::SetExtraMode(const DisplayMode& mode)
DWORD disp = 0;
LONG ec = RegCreateKeyExW(
HKEY_LOCAL_MACHINE,
LGIDD_REGKEY,
RegistryKey(),
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,
NULL, &hKey, &disp);
@@ -142,7 +140,7 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
HKEY hKey = nullptr;
LONG ec = RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
LGIDD_REGKEY,
RegistryKey(),
0,
KEY_QUERY_VALUE,
&hKey
@@ -188,51 +186,6 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
return std::wstring(buf.data());
}
bool CSettings::ReadBoolValue(const wchar_t* name, bool defaultValue)
{
HKEY hKey = nullptr;
LONG ec = RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
LGIDD_REGKEY,
0,
KEY_QUERY_VALUE,
&hKey
);
if (ec != ERROR_SUCCESS)
return defaultValue;
DWORD type = 0;
DWORD cb = 0;
ec = RegQueryValueExW(hKey, name, nullptr, &type, nullptr, &cb);
if (ec != ERROR_SUCCESS || type != REG_DWORD || cb != sizeof(DWORD))
{
RegCloseKey(hKey);
return defaultValue;
}
DWORD value = 0;
DWORD type2 = 0;
DWORD cb2 = sizeof(value);
ec = RegQueryValueExW(
hKey,
name,
nullptr,
&type2,
reinterpret_cast<LPBYTE>(&value),
&cb2
);
RegCloseKey(hKey);
if (ec != ERROR_SUCCESS || type2 != REG_DWORD || cb2 != sizeof(DWORD))
return defaultValue;
return value != 0;
}
bool CSettings::GetExtraMode(DisplayMode& mode)
{
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);
@@ -250,7 +203,7 @@ unsigned CSettings::GetDefaultRefreshMilliHz() const
{
HKEY hKey = nullptr;
LONG status = RegOpenKeyExW(
HKEY_LOCAL_MACHINE, LGIDD_REGKEY, 0, KEY_QUERY_VALUE, &hKey);
HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey);
if (status != ERROR_SUCCESS)
return 60000;
@@ -291,7 +244,8 @@ bool CSettings::ReadMultiStringValue(const wchar_t * name,
std::vector<std::wstring>& out) const
{
HKEY hKey = nullptr;
LONG st = RegOpenKeyExW(HKEY_LOCAL_MACHINE, LGIDD_REGKEY, 0, KEY_QUERY_VALUE, &hKey);
LONG st = RegOpenKeyExW(
HKEY_LOCAL_MACHINE, RegistryKey(), 0, KEY_QUERY_VALUE, &hKey);
if (st != ERROR_SUCCESS)
return false;

View File

@@ -47,9 +47,61 @@ class CSettings
unsigned GetDefaultRefreshMilliHz() const;
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* defaultValue = nullptr);
bool ReadBoolValue(const wchar_t* name, bool defaultValue = false);
static bool ReadBoolValue(
const wchar_t * name, bool defaultValue = false)
{
HKEY hKey = nullptr;
LONG status = RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
RegistryKey(),
0,
KEY_QUERY_VALUE,
&hKey);
if (status != ERROR_SUCCESS)
return defaultValue;
DWORD type = 0;
DWORD size = 0;
status = RegQueryValueExW(
hKey, name, nullptr, &type, nullptr, &size);
if (status != ERROR_SUCCESS ||
type != REG_DWORD ||
size != sizeof(DWORD))
{
RegCloseKey(hKey);
return defaultValue;
}
DWORD value = 0;
DWORD valueType = 0;
DWORD valueSize = sizeof(value);
status = RegQueryValueExW(
hKey,
name,
nullptr,
&valueType,
reinterpret_cast<LPBYTE>(&value),
&valueSize);
RegCloseKey(hKey);
if (status != ERROR_SUCCESS ||
valueType != REG_DWORD ||
valueSize != sizeof(value))
return defaultValue;
return value != 0;
}
static bool ShouldLogStatistics()
{
return ReadBoolValue(L"LogStatistics");
}
private:
static const wchar_t * RegistryKey()
{
return L"SOFTWARE\\LookingGlass\\IDD";
}
bool ReadMultiStringValue(const wchar_t * name,
std::vector<std::wstring>& out) const;
bool ReadModesValue(std::vector<std::wstring> &out) const;

View File

@@ -20,6 +20,7 @@
#include "ipc/CInputPipeServer.h"
#include "config/CSettings.h"
#include "CDebug.h"
#include "CSRWLock.h"
#include "InputPipeProtocol.h"
@@ -505,6 +506,9 @@ void CInputPipeServer::LogStatistics()
resyncDiscarded || sent || stale || writeFailed || slowWrites))
return;
if (!g_settings.ShouldLogStatistics())
return;
const double writeMs = m_performanceFrequency.QuadPart ?
static_cast<double>(writeTicks) * 1000.0 /
m_performanceFrequency.QuadPart : 0.0;

View File

@@ -20,6 +20,7 @@
#include "transport/lgmp/CLGMPInputTransport.h"
#include "config/CSettings.h"
#include "transport/lgmp/CLGMPHost.h"
#include "Atomic.h"
#include "CDebug.h"
@@ -644,6 +645,9 @@ void CLGMPInputTransport::LogStatistics(ULONGLONG now)
!statistics.releases && !statistics.deliveryFailures)
return;
if (!g_settings.ShouldLogStatistics())
return;
const double elapsed =
static_cast<double>(now - statistics.lastLog) / 1000.0;
DEBUG_TRACE("LGMP input host: %.1f msg/s, %llu reports, "

View File

@@ -21,6 +21,7 @@
#include "CHIDDevice.h"
#include "CDebug.h"
#include "config/CSettings.h"
#include "CSRWLock.h"
#include "HIDReports.h"
#include "ipc/CInputPipeClient.h"
@@ -671,6 +672,9 @@ void CHIDDevice::LogStatistics()
statistics.overflows || statistics.resetDiscarded))
return;
if (!CSettings::ShouldLogStatistics())
return;
DEBUG_TRACE("HID reports: %llu direct, %llu queued, peak %zu; "
"%llu relative and %llu absolute coalesced, %llu stale absolute "
"compacted, %llu keyboard and %llu consumer duplicates, "

View File

@@ -80,7 +80,7 @@
<WppRecorderEnabled>true</WppRecorderEnabled>
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">Trace.h</WppScanConfigurationData>
<AdditionalOptions>/EHsc /D_ATL_NO_WIN_SUPPORT %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(ProjectDir)..\LGCommon;$(ProjectDir)..\..\common\include;$(DDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\LGCommon;$(ProjectDir)..\LGIdd;$(ProjectDir)..\..\common\include;$(DDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib</AdditionalDependencies>

View File

@@ -21,6 +21,7 @@
#include "CInputPipeClient.h"
#include "CDebug.h"
#include "config/CSettings.h"
#include "InputPipeProtocol.h"
#include "../CHIDDevice.h"
#include "../HIDReports.h"
@@ -335,7 +336,8 @@ void CInputPipeClient::LogStatistics(bool force)
m_statSubmitFailed = 0;
m_lastStatistics = now;
if (received || malformed || sequenceResets || submitFailed)
if ((received || malformed || sequenceResets || submitFailed) &&
CSettings::ShouldLogStatistics())
{
DEBUG_TRACE("LGInput pipe receive: %llu reports, %llu malformed, "
"%llu sequence resets, %llu HID submit failures",