Skip to content

Commit 32d92af

Browse files
Merge branch 'gtd-main' into feature/input_update
2 parents f773344 + 5c048b2 commit 32d92af

File tree

101 files changed

+1207
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1207
-721
lines changed

IntelPresentMon/AppCef/Web/src/core/preferences.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface Preferences {
2727
metricPollRate: number;
2828
overlayDrawRate: number;
2929
telemetrySamplingPeriodMs: number;
30+
etwFlushPeriod: number;
31+
manualEtwFlush: boolean;
3032
metricsOffset: number;
3133
metricsWindow: number;
3234
overlayPosition: OverlayPosition;
@@ -65,8 +67,10 @@ export function makeDefaultPreferences(): Preferences {
6567
independentWindow: false,
6668
metricPollRate: 40,
6769
overlayDrawRate: 10,
68-
telemetrySamplingPeriodMs: 100,
69-
metricsOffset: 1020,
70+
telemetrySamplingPeriodMs: 100,
71+
etwFlushPeriod: 8,
72+
manualEtwFlush: true,
73+
metricsOffset: 32,
7074
metricsWindow: 1000,
7175
overlayPosition: 0,
7276
timeRange: 10,
@@ -104,7 +108,7 @@ export function makeDefaultPreferences(): Preferences {
104108

105109
export const signature: Signature = {
106110
code: "p2c-cap-pref",
107-
version: "0.17.0",
111+
version: "0.18.0",
108112
};
109113

110114
export interface PreferenceFile {
@@ -138,6 +142,15 @@ const migrations: Migration[] = [
138142
prefs.overlayDrawRate = drawRate;
139143
}
140144
},
145+
{
146+
version: '0.18.0',
147+
migrate: (prefs: Preferences) => {
148+
console.info('Migrating preferences to 0.18.0 (manualEtwFlush enable/rate)');
149+
const def = makeDefaultPreferences();
150+
prefs.manualEtwFlush = def.manualEtwFlush;
151+
prefs.etwFlushPeriod = def.etwFlushPeriod;
152+
}
153+
},
141154
];
142155

143156
migrations.sort((a, b) => compareVersions(a.version, b.version));

IntelPresentMon/AppCef/Web/src/views/MetricProcessingView.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ export default Vue.extend({
128128
Preferences.writeAttribute({ attr: 'metricsWindow', val: metricsWindow });
129129
},
130130
},
131+
etwFlushPeriod: {
132+
get(): number { return Preferences.preferences.etwFlushPeriod; },
133+
set(etwFlushPeriod: number) {
134+
Preferences.writeAttribute({ attr: 'etwFlushPeriod', val: etwFlushPeriod });
135+
},
136+
},
137+
manualEtwFlush: {
138+
get(): boolean { return Preferences.preferences.manualEtwFlush; },
139+
set(manualEtwFlush: boolean) {
140+
Preferences.writeAttribute({ attr: 'manualEtwFlush', val: manualEtwFlush });
141+
},
142+
},
131143
adapters(): Adapter[] {
132144
return Adapters.adapters;
133145
},

IntelPresentMon/AppCef/source/NanoCefProcessHandler.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
#include "SchemeHandlerFactory.h"
88
#include "DataBindAccessor.h"
99
#include <Core/source/infra/Logging.h>
10+
#include <Core/source/infra/LogSetup.h>
1011
#include "include/wrapper/cef_closure_task.h"
1112
#include <include/cef_task.h>
1213
#include "include/base/cef_callback.h"
1314
#include "util/AsyncEndpointManager.h"
1415
#include "util/CefValues.h"
1516
#include <Core/source/cli/CliOptions.h>
16-
#include <CommonUtilities/mt/Thread.h>
17-
#include <CommonUtilities/log/NamedPipeMarshallReceiver.h>
18-
#include <CommonUtilities/log/EntryMarshallInjector.h>
1917
#include <include/cef_parser.h>
2018

2119
using namespace pmon::util;
@@ -94,33 +92,7 @@ namespace p2c::client::cef
9492
std::string pipePrefix = std::format("p2c-logpipe-{}-{}", GetCurrentProcessId(), ++count);
9593
pChildCommandLine->AppendSwitchWithValue(opt.logPipeName.GetName(), pipePrefix);
9694
// launch connector thread
97-
mt::Thread{ "logconn", count, [pipePrefix] {
98-
try {
99-
// wait maximum 1.5sec for pipe to be created
100-
if (!pipe::DuplexPipe::WaitForAvailability(R"(\\.\pipe\)" + pipePrefix, 1500)) {
101-
pmlog_warn(std::format("Failed to connect to logging source server {} after waiting 1.5s", pipePrefix));
102-
return;
103-
}
104-
// retry connection maximum 3 times, every 16ms
105-
const int nAttempts = 3;
106-
for (int i = 0; i < nAttempts; i++) {
107-
try {
108-
auto pChan = log::GetDefaultChannel();
109-
auto pReceiver = std::make_shared<log::NamedPipeMarshallReceiver>(pipePrefix, log::IdentificationTable::GetPtr());
110-
auto pInjector = std::make_shared<log::EntryMarshallInjector>(pChan, std::move(pReceiver));
111-
pChan->AttachComponent(std::move(pInjector));
112-
return;
113-
}
114-
catch (const pipe::PipeError&) {
115-
std::this_thread::sleep_for(16ms);
116-
}
117-
}
118-
pmlog_warn(std::format("Failed to connect to logging source server {} after {} attempts", pipePrefix, nAttempts));
119-
}
120-
catch (...) {
121-
pmlog_error(ReportException());
122-
}
123-
} }.detach();
95+
ConnectToLoggingSourcePipe(pipePrefix, count);
12496
}
12597
}
12698

IntelPresentMon/AppCef/source/util/AsyncEndpointManager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33
#include "AsyncEndpointManager.h"
44
#include <Core/source/infra/Logging.h>
5-
#include <Core/source/infra/util/Util.h>
65
#include <algorithm>
76
#include "CefValues.h"
87
#include <include/cef_task.h>

IntelPresentMon/AppCef/source/util/MakeOverlaySpec.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ namespace p2c::client::util
3232
.graphDataWindowSize = traversedPref["timeRange"],
3333
.averagingWindowSize = traversedPref["metricsWindow"],
3434
.metricsOffset = traversedPref["metricsOffset"],
35+
.etwFlushPeriod = traversedPref["etwFlushPeriod"],
36+
.manualEtwFlush = traversedPref["manualEtwFlush"],
3537
.overlayPosition = (kern::OverlaySpec::OverlayPosition)traversedPref["overlayPosition"],
3638
.overlayWidth = traversedPref["overlayWidth"],
3739
.upscale = traversedPref["upscale"],

IntelPresentMon/AppCef/source/util/async/GetTopGpuProcess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <ranges>
99
#include <Core/source/win/GpuUtilization.h>
1010
#include <Core/source/win/ProcessMapBuilder.h>
11-
#include <Core/source/infra/util/Util.h>
11+
#include <CommonUtilities/str/String.h>
1212

1313
namespace p2c::client::util::async
1414
{
@@ -40,7 +40,7 @@ namespace p2c::client::util::async
4040
std::unordered_set<std::string> blacklistSet(blacklist.begin(), blacklist.end());
4141
// remove candidate target processes that match blacklist (lower case compare)
4242
std::erase_if(procList, [&](const win::Process& proc) {
43-
auto narrowName = infra::util::ToNarrow(proc.name);
43+
auto narrowName = ::pmon::util::str::ToNarrow(proc.name);
4444
for (auto& c : narrowName) {
4545
c = std::tolower(c);
4646
}

IntelPresentMon/AppCef/source/winmain.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,33 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
232232

233233
try {
234234
// service-as-child handling
235+
std::optional<std::string> logSvcPipe;
235236
std::optional<boost::process::child> childSvc;
236237
if (!opt.cefType && opt.svcAsChild) {
237238
using namespace std::literals;
238239
namespace bp = boost::process;
239240

241+
logSvcPipe = opt.logSvcPipe.AsOptional().value_or(
242+
std::format("pm2-child-svc-log-{}", GetCurrentProcessId()));
240243
childSvc.emplace("PresentMonService.exe"s,
241244
"--control-pipe"s, *opt.controlPipe,
242245
"--nsm-prefix"s, "pm-frame-nsm"s,
243246
"--intro-nsm"s, *opt.shmName,
244247
"--etw-session-name"s, *opt.etwSessionName,
245-
"--log-level"s, std::to_string((int)log::GlobalPolicy::Get().GetLogLevel()));
248+
"--log-level"s, std::to_string((int)log::GlobalPolicy::Get().GetLogLevel()),
249+
"--log-pipe-name"s, *logSvcPipe);
246250

247251
if (!pmon::util::win::WaitForNamedPipe(*opt.controlPipe, 1500)) {
248252
pmlog_error("timeout waiting for child service control pipe to go online");
249253
return -1;
250254
}
251255
}
252256

257+
if (!opt.cefType && opt.logSvcPipeEnable) {
258+
// connect to service's log pipe (best effort)
259+
ConnectToLoggingSourcePipe(logSvcPipe.value_or(*opt.logSvcPipe), 0);
260+
}
261+
253262
using namespace client;
254263
// cef process constellation fork control
255264
CefMainArgs main_args{ hInstance };

IntelPresentMon/CommonUtilities/CommonUtilities.vcxproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<ClInclude Include="BuildId.h" />
2323
<ClInclude Include="cli\CliFramework.h" />
2424
<ClInclude Include="Exception.h" />
25+
<ClInclude Include="IntervalWaiter.h" />
2526
<ClInclude Include="log\ChannelFlusher.h" />
2627
<ClInclude Include="log\CopyDriver.h" />
2728
<ClInclude Include="log\DiagnosticDriver.h" />
@@ -75,6 +76,10 @@
7576
<ClInclude Include="mt\Thread.h" />
7677
<ClInclude Include="pipe\CoroMutex.h" />
7778
<ClInclude Include="pipe\Pipe.h" />
79+
<ClInclude Include="pipe\SecurityMode.h" />
80+
<ClInclude Include="PrecisionWaiter.h" />
81+
<ClInclude Include="Qpc.h" />
82+
<ClInclude Include="rng\PairToRange.h" />
7883
<ClInclude Include="str\String.h" />
7984
<ClInclude Include="third\reflect.hpp" />
8085
<ClInclude Include="win\Event.h" />
@@ -83,11 +88,13 @@
8388
<ClInclude Include="win\Overlapped.h" />
8489
<ClInclude Include="win\Utilities.h" />
8590
<ClInclude Include="win\WinAPI.h" />
91+
<ClInclude Include="pipe\WrapAsio.h" />
8692
</ItemGroup>
8793
<ItemGroup>
8894
<ClCompile Include="BuildId.cpp" />
8995
<ClCompile Include="cli\CliFramework.cpp" />
9096
<ClCompile Include="Exception.cpp" />
97+
<ClCompile Include="IntervalWaiter.cpp" />
9198
<ClCompile Include="log\ChannelFlusher.cpp" />
9299
<ClCompile Include="log\CopyDriver.cpp" />
93100
<ClCompile Include="log\DiagnosticDriver.cpp" />
@@ -120,6 +127,8 @@
120127
<ClCompile Include="mt\Thread.cpp" />
121128
<ClCompile Include="pipe\CoroMutex.cpp" />
122129
<ClCompile Include="pipe\Pipe.cpp" />
130+
<ClCompile Include="PrecisionWaiter.cpp" />
131+
<ClCompile Include="Qpc.cpp" />
123132
<ClCompile Include="str\String.cpp" />
124133
<ClCompile Include="win\Event.cpp" />
125134
<ClCompile Include="win\Handle.cpp" />

IntelPresentMon/CommonUtilities/CommonUtilities.vcxproj.filters

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,24 @@
207207
<ClInclude Include="BuildId.h">
208208
<Filter>Header Files</Filter>
209209
</ClInclude>
210+
<ClInclude Include="PrecisionWaiter.h">
211+
<Filter>Header Files</Filter>
212+
</ClInclude>
213+
<ClInclude Include="Qpc.h">
214+
<Filter>Header Files</Filter>
215+
</ClInclude>
216+
<ClInclude Include="IntervalWaiter.h">
217+
<Filter>Header Files</Filter>
218+
</ClInclude>
219+
<ClInclude Include="rng\PairToRange.h">
220+
<Filter>Header Files</Filter>
221+
</ClInclude>
222+
<ClInclude Include="pipe\SecurityMode.h">
223+
<Filter>Header Files</Filter>
224+
</ClInclude>
225+
<ClInclude Include="pipe\WrapAsio.h">
226+
<Filter>Header Files</Filter>
227+
</ClInclude>
210228
</ItemGroup>
211229
<ItemGroup>
212230
<ClCompile Include="cli\CliFramework.cpp">
@@ -329,6 +347,15 @@
329347
<ClCompile Include="BuildId.cpp">
330348
<Filter>Source Files</Filter>
331349
</ClCompile>
350+
<ClCompile Include="PrecisionWaiter.cpp">
351+
<Filter>Source Files</Filter>
352+
</ClCompile>
353+
<ClCompile Include="Qpc.cpp">
354+
<Filter>Source Files</Filter>
355+
</ClCompile>
356+
<ClCompile Include="IntervalWaiter.cpp">
357+
<Filter>Source Files</Filter>
358+
</ClCompile>
332359
</ItemGroup>
333360
<ItemGroup>
334361
<None Include="vcpkg.json" />

IntelPresentMon/CommonUtilities/Exception.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,32 @@ namespace pmon::util
7575
}
7676
}
7777

78-
std::string ReportException(std::exception_ptr pEx) noexcept
78+
std::string ReportException(std::string note, std::exception_ptr pEx) noexcept
7979
{
8080
if (!pEx) {
8181
pEx = std::current_exception();
8282
}
83+
const auto concat = [&](std::string what) {
84+
if (!note.empty()) {
85+
return note + "\n" + what;
86+
}
87+
else {
88+
return what;
89+
}
90+
};
8391
if (pEx) {
8492
try {
8593
std::rethrow_exception(pEx);
8694
}
8795
catch (const std::exception& e) {
88-
try { return std::format("[{}] {}", typeid(e).name(), e.what()); }
96+
try { return concat(std::format("[{}] {}", typeid(e).name(), e.what())); }
8997
catch (...) { return {}; }
9098
}
9199
catch (...) {
92-
return "Unrecognized exception";
100+
return concat("Unrecognized exception");
93101
}
94102
}
95-
return "No exception in flight";
103+
return concat("No exception in flight");
96104
}
97105

98106
PM_STATUS GeneratePmStatus(std::exception_ptr pEx) noexcept

0 commit comments

Comments
 (0)