@ohos-perf/core 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -2
- package/dist/index.js +166 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5266,6 +5266,8 @@ declare class EmptyFrameAnalyzer implements Analyzer {
|
|
|
5266
5266
|
run(ctx: AnalyzeContext): Promise<AnalyzeResult>;
|
|
5267
5267
|
}
|
|
5268
5268
|
|
|
5269
|
+
/** Which backtracking method produced a trace. */
|
|
5270
|
+
type RsSkipTraceMethod = 'rs_api' | 'nativewindow';
|
|
5269
5271
|
/** One RenderService frame that skipped, and what it traced back to. */
|
|
5270
5272
|
interface RsSkipFrame {
|
|
5271
5273
|
frame: Frame;
|
|
@@ -5273,10 +5275,11 @@ interface RsSkipFrame {
|
|
|
5273
5275
|
events: number;
|
|
5274
5276
|
traced?: {
|
|
5275
5277
|
frame: Frame;
|
|
5276
|
-
/** The buffer event's timestamp. */
|
|
5278
|
+
/** The buffer or `UnMarsh` event's timestamp. */
|
|
5277
5279
|
eventNs: number;
|
|
5278
5280
|
/** `|appFrame.ts - eventNs|`. */
|
|
5279
5281
|
timeDiffNs: number;
|
|
5282
|
+
method: RsSkipTraceMethod;
|
|
5280
5283
|
};
|
|
5281
5284
|
}
|
|
5282
5285
|
interface RsSkipResult {
|
|
@@ -5885,4 +5888,4 @@ interface FlamegraphPageInput {
|
|
|
5885
5888
|
*/
|
|
5886
5889
|
declare function renderFlamegraphHtml(input: FlamegraphPageInput): string;
|
|
5887
5890
|
|
|
5888
|
-
export { type ActionContext, type ActionDevice, type ActionOutcome, type ActiveAlloc, type AnalyzeContext, type AnalyzeResult, type Analyzer, type AnalyzerRun, type AnalyzerSection, type AppIdentity, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, CATEGORY_EXTENSIONS, CATEGORY_MAX_BYTES, COLLECTOR_NAMES, type CallchainSample, type CallstackEvent, type CallstackEventWithArgs, CallstackQuery, type CapabilityId, type CapabilityInputs, CapabilityMatrix, type CapabilityState, type CaseLoad, type CategoryTotal, type CollectOptions, type CollectSession, type Collector, type CollectorName, type CompiledRule, type ComponentReuse, ComponentReuseAnalyzer, type ConnectOptions, type ContentPattern, type CreateEmulatorRequest, DEFAULT_HILOG_RULES, DEFAULT_QUERY_LIMIT, DEVICE_PERF_PATH, DEVICE_SCREENSHOT_PATH, DEVICE_UI_PATH, type DeltaStatus, type DepGraph, type DepGraphEdge, type DepGraphFile, Device, type DeviceDeps, type DeviceIdentity, DeviceNotFoundError, type DiscoveredCase, type DrillDownHandle, type DuplicateGroup, EXCLUDE_PATTERNS, EmptyFrameAnalyzer, type EmptyFrameFilter, type EmulatorBackend, EmulatorClient, type EmulatorClientOptions, EmulatorCommandError, type EmulatorImage, EmulatorImageMissingError, type EmulatorInstance, EmulatorLifecycle, type EmulatorLifecycleOptions, EmulatorNotFoundError, type EmulatorStartResult, type EmulatorStopResult, type Env, type Evidence, type EvidenceKind, type ExpectPresent, type ExpectationOutcome, FLAMEGRAPH_FILES, FPS_COMMAND, FTRACE_CATEGORIES, FaultTreeAnalyzer, type FaultTreeSignals, type Fidelity, type FileCategory, type FileRule, FlamegraphAnalyzer, type FlamegraphPageInput, type FoldedStack, type FpsBucket, type FpsWindow, type Frame, FrameAnalyzer, type FrameFlag, FrameLoadAnalyzer, FrameLoadIndex, type FrameLoadIndexInput, type FrameLoadThread, FrameQuery, type FrameStats, type FrameType, type FtraceOptions, GEOMETRY_TOLERANCE_PX, GcAnalyzer, type GcSignals, type Gesture, GestureDriver, type GestureResult, HILOG_COMMAND, HIPROFILER_PLUGIN_NAMES, HITCH_COMMAND, HITRACE_DEFAULT_CATEGORIES, type HapAnalysis, type HapPackage, type HarEdge, Hdc, HdcNotFoundError, type HdcOptions, type HdcResult, type HdcSlice, type HdcTarget, type HidumperCapture, HidumperCollector, type HidumperSnapshot, HilogAnalyzer, HilogCollector, type HilogLevel, type HilogLine, type HilogMatch, type HilogParseOptions, type HilogRule, type HiperfCapture, type HiperfCollectOptions, HiperfCollector, type HiprofilerCollectOptions, type HiprofilerCollectRequest, HiprofilerCollector, type HiprofilerConfigOptions, type HiprofilerPlugin, type HiprofilerPluginName, HitraceCollector, IGNORED_ATTRIBUTES, type ImageComparison, IngestError, InstantQuery, type InventoryFile, type JsheapCapture, JsheapCollector, MAX_QUERY_LIMIT, METRIC_DIRECTIONS, MIN_BUFFER_PAGES, MemMeasureQuery, MemoryAnalyzer, MemoryMeasureAnalyzer, type MemoryPluginOptions, type MetadataPattern, type Metric, type MetricDelta, type MetricDirection, type MetricUnit, type ModuleDecl, type NamedQueryDefinition, type NamedQueryInfo, type NamedQueryResult, type NativeCategory, type NativeEventKind, type NativeHookEvent, type NativeHookFrame, NativeHookQuery, type NativeHookStatistic, NativeMemoryAnalyzer, type NativeMemoryResult, type NativeNames, type NativeTimelineBucket, type NativehookOptions, OhosPerfError, type OptimizationPotential, type OversizedFile, PARITY_ROWS, PLANE_A_PLUGINS, type ParityRow, type ParityStatus, type PerfCallchain, type PerfFileAttribution, type PerfFunction, type PerfLeafAttribution, PerfQuery, type PerfSampleRow, type PerfThread, type ProbeResult, type ProbeRunner, type ProbeSnapshot, type ProcessInfo, type ProcessMeasure, type ProcessMeasureFilter, ProcessQuery, ProcfsCollector, type ProcfsSample, type ProcfsStatus, type Provenance, type QueryArgument, type QueryContext, type QueryHandle, REPORT_SCHEMA_VERSION, type Rect, type RedundancyLevel, type RedundancyType, RedundantFileAnalyzer, type RedundantFileEntry, type RedundantFileReport, type RedundantThreadPattern, type RedundantThreadsSummary, RenderAnalyzer, type ReportGenerator, type ReportInput, type ReportModel, type ReportScenario, type ReportSection, type ReportSummary, type ReportTotals, type RgbaImage, RsSkipAnalyzer, type RsSkipFrame, type RsSkipResult, type RuleMatch, type RuleMatchKind, type RunOptions, type RunResult, type RunStepResult, type RunnerCollectOptions, type RunnerDevice, SECTION_TITLES, type Scenario, type ScenarioAction, ScenarioRunner, type ScenarioStep, Scene, type SceneLayout, type SceneMetadata, type SceneStep, type SceneStepRef, type ScenesComparison, SchedQuery, type SchedSlice, type ScreenshotCapture, ScreenshotCollector, type Selector, type SelectorRect, type SmapsRollup, StartupAnalyzer, StartupQuery, type StartupRecord, type StepCapture, type StepComparison, type StepExpectation, type StepStatus, Streamer, StreamerNotFoundError, type StreamerOptions, type SymbolStat, SymbolsAnalyzer, TECH_RULES, type TechRule, type ThreadAnalysis, type ThreadAnalysisSummary, ThreadAnalyzer, type ThreadInfo, ThreadQuery, type ThreadState, ThreadStateQuery, type ThreadWakeupResult, type ThreadWakeupThread, type TimeRange, type TimingCycle, type TraceCollectOptions, UI_DIFF_FILES, UiAnalyzer, type UiCompareOptions, type UiDiff, type UiDiffSide, type UiNode, type UiTreeDiff, type UiTreeDifference, UitestCollector, type UnreleasedRow, type VsyncAnalysis, VsyncAnalyzer, type VsyncPeriod, type VsyncPeriodKind, type VsyncSeverity, type WakeupEvent, type WindowHitches, type ZipArchive, type ZipEntry, aggregateUnreleased, analyzeHap, analyzeThreadWakeup, buildDepGraph, buildHiprofilerConfig, buildInventory, buildMatrix, buildNativeTimeline, buildReport, categorize, classifyNativePath, compareImages, compareResults, compareSceneDirs, compareScenes, compileRules, computeBinderAnalysis, computeComponentReuse, computeFaultTree, computeFpsWindows, computeGc, computeRsSkip, computeThreadAnalysis, computeVsyncAnomalies, connect, createSceneLayout, decodePng, defaultAnalyzers, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hiperfRecordCommand, ingestScene, isUnresolvedSymbol, isZip, loadCases, lookupQuery, markRegions, matchHapRules, matchRules, matchSelector, memoryPlugin, metric, nativeEventKind, nativehookPlugin, nodeIdentity, openDb, openZip, pairNativeMemory, paritySummary, parseBounds, parseFpsCounts, parseHilogLine, parseHilogText, parseHiperfSummary, parseHitches, parseProcfsStatus, parseRedundantFile, parseScenario, parseSelector, parseSmapsRollup, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderEvidenceCsv, renderFlamegraphHtml, renderFlamegraphSvg, renderMetricsCsv, renderReportHtml, renderReportJson, renderReportXlsx, renderScenesComparison, renderSummaryJson, renderUiDiffHtml, resolveAppIdentity, resolveAppIpids, resolveQueryLimit, resolveSelector, round2HalfEven, runAnalyzerSections, runAnalyzers, runDrillDown, runNamedQuery, runProbe, sortSteps, summarizeReport, tableRowCounts, unknownQueryError, validateRules, writeProcfsSamples, writeRunFiles, writeSceneMetadata, xpowerPlugin };
|
|
5891
|
+
export { type ActionContext, type ActionDevice, type ActionOutcome, type ActiveAlloc, type AnalyzeContext, type AnalyzeResult, type Analyzer, type AnalyzerRun, type AnalyzerSection, type AppIdentity, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, CATEGORY_EXTENSIONS, CATEGORY_MAX_BYTES, COLLECTOR_NAMES, type CallchainSample, type CallstackEvent, type CallstackEventWithArgs, CallstackQuery, type CapabilityId, type CapabilityInputs, CapabilityMatrix, type CapabilityState, type CaseLoad, type CategoryTotal, type CollectOptions, type CollectSession, type Collector, type CollectorName, type CompiledRule, type ComponentReuse, ComponentReuseAnalyzer, type ConnectOptions, type ContentPattern, type CreateEmulatorRequest, DEFAULT_HILOG_RULES, DEFAULT_QUERY_LIMIT, DEVICE_PERF_PATH, DEVICE_SCREENSHOT_PATH, DEVICE_UI_PATH, type DeltaStatus, type DepGraph, type DepGraphEdge, type DepGraphFile, Device, type DeviceDeps, type DeviceIdentity, DeviceNotFoundError, type DiscoveredCase, type DrillDownHandle, type DuplicateGroup, EXCLUDE_PATTERNS, EmptyFrameAnalyzer, type EmptyFrameFilter, type EmulatorBackend, EmulatorClient, type EmulatorClientOptions, EmulatorCommandError, type EmulatorImage, EmulatorImageMissingError, type EmulatorInstance, EmulatorLifecycle, type EmulatorLifecycleOptions, EmulatorNotFoundError, type EmulatorStartResult, type EmulatorStopResult, type Env, type Evidence, type EvidenceKind, type ExpectPresent, type ExpectationOutcome, FLAMEGRAPH_FILES, FPS_COMMAND, FTRACE_CATEGORIES, FaultTreeAnalyzer, type FaultTreeSignals, type Fidelity, type FileCategory, type FileRule, FlamegraphAnalyzer, type FlamegraphPageInput, type FoldedStack, type FpsBucket, type FpsWindow, type Frame, FrameAnalyzer, type FrameFlag, FrameLoadAnalyzer, FrameLoadIndex, type FrameLoadIndexInput, type FrameLoadThread, FrameQuery, type FrameStats, type FrameType, type FtraceOptions, GEOMETRY_TOLERANCE_PX, GcAnalyzer, type GcSignals, type Gesture, GestureDriver, type GestureResult, HILOG_COMMAND, HIPROFILER_PLUGIN_NAMES, HITCH_COMMAND, HITRACE_DEFAULT_CATEGORIES, type HapAnalysis, type HapPackage, type HarEdge, Hdc, HdcNotFoundError, type HdcOptions, type HdcResult, type HdcSlice, type HdcTarget, type HidumperCapture, HidumperCollector, type HidumperSnapshot, HilogAnalyzer, HilogCollector, type HilogLevel, type HilogLine, type HilogMatch, type HilogParseOptions, type HilogRule, type HiperfCapture, type HiperfCollectOptions, HiperfCollector, type HiprofilerCollectOptions, type HiprofilerCollectRequest, HiprofilerCollector, type HiprofilerConfigOptions, type HiprofilerPlugin, type HiprofilerPluginName, HitraceCollector, IGNORED_ATTRIBUTES, type ImageComparison, IngestError, InstantQuery, type InventoryFile, type JsheapCapture, JsheapCollector, MAX_QUERY_LIMIT, METRIC_DIRECTIONS, MIN_BUFFER_PAGES, MemMeasureQuery, MemoryAnalyzer, MemoryMeasureAnalyzer, type MemoryPluginOptions, type MetadataPattern, type Metric, type MetricDelta, type MetricDirection, type MetricUnit, type ModuleDecl, type NamedQueryDefinition, type NamedQueryInfo, type NamedQueryResult, type NativeCategory, type NativeEventKind, type NativeHookEvent, type NativeHookFrame, NativeHookQuery, type NativeHookStatistic, NativeMemoryAnalyzer, type NativeMemoryResult, type NativeNames, type NativeTimelineBucket, type NativehookOptions, OhosPerfError, type OptimizationPotential, type OversizedFile, PARITY_ROWS, PLANE_A_PLUGINS, type ParityRow, type ParityStatus, type PerfCallchain, type PerfFileAttribution, type PerfFunction, type PerfLeafAttribution, PerfQuery, type PerfSampleRow, type PerfThread, type ProbeResult, type ProbeRunner, type ProbeSnapshot, type ProcessInfo, type ProcessMeasure, type ProcessMeasureFilter, ProcessQuery, ProcfsCollector, type ProcfsSample, type ProcfsStatus, type Provenance, type QueryArgument, type QueryContext, type QueryHandle, REPORT_SCHEMA_VERSION, type Rect, type RedundancyLevel, type RedundancyType, RedundantFileAnalyzer, type RedundantFileEntry, type RedundantFileReport, type RedundantThreadPattern, type RedundantThreadsSummary, RenderAnalyzer, type ReportGenerator, type ReportInput, type ReportModel, type ReportScenario, type ReportSection, type ReportSummary, type ReportTotals, type RgbaImage, RsSkipAnalyzer, type RsSkipFrame, type RsSkipResult, type RsSkipTraceMethod, type RuleMatch, type RuleMatchKind, type RunOptions, type RunResult, type RunStepResult, type RunnerCollectOptions, type RunnerDevice, SECTION_TITLES, type Scenario, type ScenarioAction, ScenarioRunner, type ScenarioStep, Scene, type SceneLayout, type SceneMetadata, type SceneStep, type SceneStepRef, type ScenesComparison, SchedQuery, type SchedSlice, type ScreenshotCapture, ScreenshotCollector, type Selector, type SelectorRect, type SmapsRollup, StartupAnalyzer, StartupQuery, type StartupRecord, type StepCapture, type StepComparison, type StepExpectation, type StepStatus, Streamer, StreamerNotFoundError, type StreamerOptions, type SymbolStat, SymbolsAnalyzer, TECH_RULES, type TechRule, type ThreadAnalysis, type ThreadAnalysisSummary, ThreadAnalyzer, type ThreadInfo, ThreadQuery, type ThreadState, ThreadStateQuery, type ThreadWakeupResult, type ThreadWakeupThread, type TimeRange, type TimingCycle, type TraceCollectOptions, UI_DIFF_FILES, UiAnalyzer, type UiCompareOptions, type UiDiff, type UiDiffSide, type UiNode, type UiTreeDiff, type UiTreeDifference, UitestCollector, type UnreleasedRow, type VsyncAnalysis, VsyncAnalyzer, type VsyncPeriod, type VsyncPeriodKind, type VsyncSeverity, type WakeupEvent, type WindowHitches, type ZipArchive, type ZipEntry, aggregateUnreleased, analyzeHap, analyzeThreadWakeup, buildDepGraph, buildHiprofilerConfig, buildInventory, buildMatrix, buildNativeTimeline, buildReport, categorize, classifyNativePath, compareImages, compareResults, compareSceneDirs, compareScenes, compileRules, computeBinderAnalysis, computeComponentReuse, computeFaultTree, computeFpsWindows, computeGc, computeRsSkip, computeThreadAnalysis, computeVsyncAnomalies, connect, createSceneLayout, decodePng, defaultAnalyzers, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hiperfRecordCommand, ingestScene, isUnresolvedSymbol, isZip, loadCases, lookupQuery, markRegions, matchHapRules, matchRules, matchSelector, memoryPlugin, metric, nativeEventKind, nativehookPlugin, nodeIdentity, openDb, openZip, pairNativeMemory, paritySummary, parseBounds, parseFpsCounts, parseHilogLine, parseHilogText, parseHiperfSummary, parseHitches, parseProcfsStatus, parseRedundantFile, parseScenario, parseSelector, parseSmapsRollup, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderEvidenceCsv, renderFlamegraphHtml, renderFlamegraphSvg, renderMetricsCsv, renderReportHtml, renderReportJson, renderReportXlsx, renderScenesComparison, renderSummaryJson, renderUiDiffHtml, resolveAppIdentity, resolveAppIpids, resolveQueryLimit, resolveSelector, round2HalfEven, runAnalyzerSections, runAnalyzers, runDrillDown, runNamedQuery, runProbe, sortSteps, summarizeReport, tableRowCounts, unknownQueryError, validateRules, writeProcfsSamples, writeRunFiles, writeSceneMetadata, xpowerPlugin };
|
package/dist/index.js
CHANGED
|
@@ -6071,8 +6071,8 @@ var PARITY_ROWS = [
|
|
|
6071
6071
|
{
|
|
6072
6072
|
row: 12,
|
|
6073
6073
|
name: "RenderService skip reverse tracing",
|
|
6074
|
-
status: "
|
|
6075
|
-
reason: "
|
|
6074
|
+
status: "ported",
|
|
6075
|
+
reason: "",
|
|
6076
6076
|
analyzer: "RsSkipAnalyzer"
|
|
6077
6077
|
},
|
|
6078
6078
|
{
|
|
@@ -15389,6 +15389,8 @@ var EVENT_LOOKBACK_NS = 5e8;
|
|
|
15389
15389
|
var APP_LOOKAHEAD_NS = 1e7;
|
|
15390
15390
|
var MAX_EVENTS = 5;
|
|
15391
15391
|
var MAX_APP_FRAMES = 10;
|
|
15392
|
+
var WAKEUP_WINDOW_NS = 1e7;
|
|
15393
|
+
var MAX_CHAIN_DEPTH = 5;
|
|
15392
15394
|
function nearest(values, anchor, before, after, limit) {
|
|
15393
15395
|
return values.filter((value) => value >= anchor - before && value <= anchor + after).sort((a, b) => {
|
|
15394
15396
|
const distance = Math.abs(a - anchor) - Math.abs(b - anchor);
|
|
@@ -15404,6 +15406,81 @@ function renderServiceIpids(processes) {
|
|
|
15404
15406
|
}
|
|
15405
15407
|
return ipids;
|
|
15406
15408
|
}
|
|
15409
|
+
function hasTable3(db, name) {
|
|
15410
|
+
return db.query(
|
|
15411
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",
|
|
15412
|
+
[name]
|
|
15413
|
+
).length > 0;
|
|
15414
|
+
}
|
|
15415
|
+
var UNMARSH_PID = /recv data from (\d+)/;
|
|
15416
|
+
function parseUnmarshPid(name) {
|
|
15417
|
+
const match = UNMARSH_PID.exec(name);
|
|
15418
|
+
return match === null ? void 0 : Number(match[1]);
|
|
15419
|
+
}
|
|
15420
|
+
function readApiCaches(db, rsIpids) {
|
|
15421
|
+
if (!hasTable3(db, "instant")) return void 0;
|
|
15422
|
+
const wakeups = /* @__PURE__ */ new Map();
|
|
15423
|
+
const rows = db.query(
|
|
15424
|
+
`SELECT ref, wakeup_from, ts FROM instant
|
|
15425
|
+
WHERE name = 'sched_wakeup' AND ref_type = 'itid'
|
|
15426
|
+
AND ref IS NOT NULL AND wakeup_from IS NOT NULL AND ts IS NOT NULL
|
|
15427
|
+
ORDER BY ref, ts DESC`
|
|
15428
|
+
);
|
|
15429
|
+
for (const row2 of rows) {
|
|
15430
|
+
if (row2.ref === null || row2.wakeup_from === null || row2.ts === null) continue;
|
|
15431
|
+
const list = wakeups.get(row2.ref);
|
|
15432
|
+
if (list === void 0) wakeups.set(row2.ref, [{ from: row2.wakeup_from, ts: row2.ts }]);
|
|
15433
|
+
else list.push({ from: row2.wakeup_from, ts: row2.ts });
|
|
15434
|
+
}
|
|
15435
|
+
const threadPid = /* @__PURE__ */ new Map();
|
|
15436
|
+
const uiThread = /* @__PURE__ */ new Map();
|
|
15437
|
+
for (const row2 of db.query(
|
|
15438
|
+
`SELECT t.id, t.name, p.pid, p.name AS process
|
|
15439
|
+
FROM thread t JOIN process p ON t.ipid = p.ipid
|
|
15440
|
+
ORDER BY t.id`
|
|
15441
|
+
)) {
|
|
15442
|
+
threadPid.set(row2.id, row2.pid);
|
|
15443
|
+
const named = row2.name === row2.process;
|
|
15444
|
+
const uiLike = row2.name !== null && (row2.name.includes("UI") || row2.name.includes("ui"));
|
|
15445
|
+
if ((named || uiLike) && !uiThread.has(row2.pid)) uiThread.set(row2.pid, row2.id);
|
|
15446
|
+
}
|
|
15447
|
+
const rsMarks = rsIpids.map(() => "?").join(", ");
|
|
15448
|
+
const unmarsh = [];
|
|
15449
|
+
for (const row2 of db.query(
|
|
15450
|
+
`SELECT c.ts, c.callid, c.name FROM callstack c
|
|
15451
|
+
JOIN thread t ON c.callid = t.id
|
|
15452
|
+
WHERE t.ipid IN (${rsMarks}) AND c.name LIKE '%UnMarsh RSTransactionData%'
|
|
15453
|
+
ORDER BY c.ts`,
|
|
15454
|
+
[...rsIpids]
|
|
15455
|
+
)) {
|
|
15456
|
+
if (row2.ts === null || row2.callid === null || row2.name === null) continue;
|
|
15457
|
+
const pid = parseUnmarshPid(row2.name);
|
|
15458
|
+
if (pid === void 0) continue;
|
|
15459
|
+
unmarsh.push({ ts: row2.ts, itid: row2.callid, pid });
|
|
15460
|
+
}
|
|
15461
|
+
return { wakeups, threadPid, uiThread, unmarsh };
|
|
15462
|
+
}
|
|
15463
|
+
function nearestWakeup(caches, itid, ts, before, after) {
|
|
15464
|
+
let best;
|
|
15465
|
+
let bestDiff = Infinity;
|
|
15466
|
+
for (const wakeup of caches.wakeups.get(itid) ?? []) {
|
|
15467
|
+
if (wakeup.ts < ts - before || wakeup.ts > ts + after) continue;
|
|
15468
|
+
const diff = Math.abs(wakeup.ts - ts);
|
|
15469
|
+
if (diff < bestDiff) {
|
|
15470
|
+
bestDiff = diff;
|
|
15471
|
+
best = wakeup;
|
|
15472
|
+
}
|
|
15473
|
+
}
|
|
15474
|
+
return best;
|
|
15475
|
+
}
|
|
15476
|
+
function appThreadFor(caches, ipcItid, eventNs, appPid) {
|
|
15477
|
+
let current = nearestWakeup(caches, ipcItid, eventNs, WAKEUP_WINDOW_NS, WAKEUP_WINDOW_NS);
|
|
15478
|
+
for (let depth = 0; depth < MAX_CHAIN_DEPTH && current !== void 0; depth += 1) {
|
|
15479
|
+
if (caches.threadPid.get(current.from) === appPid) return current.from;
|
|
15480
|
+
current = nearestWakeup(caches, current.from, current.ts, EVENT_LOOKBACK_NS, 0);
|
|
15481
|
+
}
|
|
15482
|
+
return void 0;
|
|
15483
|
+
}
|
|
15407
15484
|
function computeRsSkip(db, opts) {
|
|
15408
15485
|
if (opts.rsIpids.length === 0) return { frames: [], totalEvents: 0 };
|
|
15409
15486
|
const rsMarks = opts.rsIpids.map(() => "?").join(", ");
|
|
@@ -15472,8 +15549,41 @@ ORDER BY c.ts`,
|
|
|
15472
15549
|
if (existing === void 0 || frame.id < existing.id) appByTs.set(frame.ts, frame);
|
|
15473
15550
|
}
|
|
15474
15551
|
const appTs = [...appByTs.keys()].sort((a, b) => a - b);
|
|
15552
|
+
const api = readApiCaches(db, opts.rsIpids);
|
|
15553
|
+
const appPidSet = /* @__PURE__ */ new Set();
|
|
15554
|
+
for (const ipid of opts.appIpids) {
|
|
15555
|
+
const row2 = db.query(
|
|
15556
|
+
"SELECT pid FROM process WHERE ipid = ? ORDER BY id LIMIT 1",
|
|
15557
|
+
[ipid]
|
|
15558
|
+
)[0];
|
|
15559
|
+
if (row2?.pid !== null && row2?.pid !== void 0) appPidSet.add(row2.pid);
|
|
15560
|
+
}
|
|
15561
|
+
const apiTrace = (frame) => {
|
|
15562
|
+
if (api === void 0) return void 0;
|
|
15563
|
+
const inWindow = api.unmarsh.filter(
|
|
15564
|
+
(event) => event.ts >= frame.ts - EVENT_LOOKBACK_NS && event.ts <= frame.ts + frame.dur
|
|
15565
|
+
);
|
|
15566
|
+
inWindow.sort((a, b) => Math.abs(a.ts - frame.ts) - Math.abs(b.ts - frame.ts) || a.ts - b.ts);
|
|
15567
|
+
let best;
|
|
15568
|
+
for (const event of inWindow.slice(0, MAX_EVENTS)) {
|
|
15569
|
+
if (!appPidSet.has(event.pid)) continue;
|
|
15570
|
+
const threadItid = appThreadFor(api, event.itid, event.ts, event.pid);
|
|
15571
|
+
if (threadItid === void 0) continue;
|
|
15572
|
+
const near = nearest(appTs, event.ts, EVENT_LOOKBACK_NS, APP_LOOKAHEAD_NS, MAX_APP_FRAMES);
|
|
15573
|
+
for (const ts of near) {
|
|
15574
|
+
const match = appByTs.get(ts);
|
|
15575
|
+
if (match === void 0 || match.itid !== threadItid) continue;
|
|
15576
|
+
const timeDiffNs = Math.abs(ts - event.ts);
|
|
15577
|
+
if (best !== void 0 && timeDiffNs >= best.timeDiffNs) continue;
|
|
15578
|
+
best = { frame: match, eventNs: event.ts, timeDiffNs, method: "rs_api" };
|
|
15579
|
+
}
|
|
15580
|
+
}
|
|
15581
|
+
return best;
|
|
15582
|
+
};
|
|
15475
15583
|
const traced = frames.map((entry) => {
|
|
15476
15584
|
const frame = entry.frame;
|
|
15585
|
+
const viaApi = apiTrace(frame);
|
|
15586
|
+
if (viaApi !== void 0) return { ...entry, traced: viaApi };
|
|
15477
15587
|
const candidates = nearest(bufferTs, frame.ts, EVENT_LOOKBACK_NS, frame.dur, MAX_EVENTS);
|
|
15478
15588
|
let best;
|
|
15479
15589
|
for (const eventNs of candidates) {
|
|
@@ -15483,7 +15593,7 @@ ORDER BY c.ts`,
|
|
|
15483
15593
|
if (best !== void 0 && timeDiffNs >= best.timeDiffNs) continue;
|
|
15484
15594
|
const match = appByTs.get(ts);
|
|
15485
15595
|
if (match === void 0) continue;
|
|
15486
|
-
best = { frame: match, eventNs, timeDiffNs };
|
|
15596
|
+
best = { frame: match, eventNs, timeDiffNs, method: "nativewindow" };
|
|
15487
15597
|
}
|
|
15488
15598
|
}
|
|
15489
15599
|
return { ...entry, ...best === void 0 ? {} : { traced: best } };
|
|
@@ -15493,6 +15603,26 @@ ORDER BY c.ts`,
|
|
|
15493
15603
|
function allFrames(db, window) {
|
|
15494
15604
|
return new FrameQuery(db).all(window);
|
|
15495
15605
|
}
|
|
15606
|
+
function instructionWaste(ctx, frames) {
|
|
15607
|
+
if (ctx.perf === void 0 || !ctx.perf.hasSamples()) return void 0;
|
|
15608
|
+
if (ctx.app.pids.length === 0) return void 0;
|
|
15609
|
+
const tracedFrames = frames.map((entry) => entry.traced?.frame).filter((frame) => frame !== void 0);
|
|
15610
|
+
if (tracedFrames.length === 0) return void 0;
|
|
15611
|
+
const firstTs = tracedFrames.reduce((min, frame) => Math.min(min, frame.ts), tracedFrames[0].ts);
|
|
15612
|
+
const lastEnd = tracedFrames.reduce(
|
|
15613
|
+
(max, frame) => Math.max(max, frame.ts + Math.max(0, frame.dur)),
|
|
15614
|
+
tracedFrames[0].ts + Math.max(0, tracedFrames[0].dur)
|
|
15615
|
+
);
|
|
15616
|
+
const index = FrameLoadIndex.build({
|
|
15617
|
+
perf: ctx.perf,
|
|
15618
|
+
pids: ctx.app.pids,
|
|
15619
|
+
range: { startNs: firstTs, endNs: lastEnd }
|
|
15620
|
+
});
|
|
15621
|
+
if (index === void 0) return void 0;
|
|
15622
|
+
let total = 0;
|
|
15623
|
+
for (const frame of tracedFrames) total += index.load(frame);
|
|
15624
|
+
return total > 0 ? total : void 0;
|
|
15625
|
+
}
|
|
15496
15626
|
function byMetricId12(a, b) {
|
|
15497
15627
|
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
15498
15628
|
}
|
|
@@ -15586,6 +15716,37 @@ var RsSkipAnalyzer = class {
|
|
|
15586
15716
|
})
|
|
15587
15717
|
);
|
|
15588
15718
|
}
|
|
15719
|
+
const instructions = instructionWaste(ctx, result.frames);
|
|
15720
|
+
if (instructions !== void 0) {
|
|
15721
|
+
metrics.push(
|
|
15722
|
+
metric({
|
|
15723
|
+
id: "rs_skip.cpu_waste.instructions",
|
|
15724
|
+
value: instructions,
|
|
15725
|
+
unit: "count",
|
|
15726
|
+
provenance: { collector: "hiperf", table: "perf_sample", device: ctx.deviceId },
|
|
15727
|
+
fidelity: "exact",
|
|
15728
|
+
window: ctx.window
|
|
15729
|
+
})
|
|
15730
|
+
);
|
|
15731
|
+
}
|
|
15732
|
+
const byMethod = { rs_api: 0, nativewindow: 0 };
|
|
15733
|
+
for (const entry of result.frames) {
|
|
15734
|
+
if (entry.traced !== void 0) byMethod[entry.traced.method] += 1;
|
|
15735
|
+
}
|
|
15736
|
+
if (traced > 0) {
|
|
15737
|
+
for (const method of ["rs_api", "nativewindow"]) {
|
|
15738
|
+
metrics.push(
|
|
15739
|
+
metric({
|
|
15740
|
+
id: `rs_skip.traced.${method}.count`,
|
|
15741
|
+
value: byMethod[method],
|
|
15742
|
+
unit: "count",
|
|
15743
|
+
provenance: prov,
|
|
15744
|
+
fidelity: "exact",
|
|
15745
|
+
window: ctx.window
|
|
15746
|
+
})
|
|
15747
|
+
);
|
|
15748
|
+
}
|
|
15749
|
+
}
|
|
15589
15750
|
} else {
|
|
15590
15751
|
metrics.push(
|
|
15591
15752
|
metric({
|
|
@@ -15634,9 +15795,9 @@ var RsSkipAnalyzer = class {
|
|
|
15634
15795
|
appFrameId: match.frame.id,
|
|
15635
15796
|
appFrameFlag: match.frame.flag,
|
|
15636
15797
|
timeDiffMs: match.timeDiffNs / 1e6,
|
|
15637
|
-
method:
|
|
15798
|
+
method: match.method
|
|
15638
15799
|
},
|
|
15639
|
-
explain: match === void 0 ? `render_service skipped ${entry.events} frame(s) at vsync ${frame.vsync}; no app frame could be traced back to it` : `render_service skipped the frame at vsync ${frame.vsync}; ${appProcessName13(ctx)} frame ${match.frame.id} fed it (${(match.timeDiffNs / 1e6).toFixed(2)}ms from its buffer event)
|
|
15800
|
+
explain: match === void 0 ? `render_service skipped ${entry.events} frame(s) at vsync ${frame.vsync}; no app frame could be traced back to it` : `render_service skipped the frame at vsync ${frame.vsync}; ${appProcessName13(ctx)} frame ${match.frame.id} fed it ` + (match.method === "rs_api" ? `(${(match.timeDiffNs / 1e6).toFixed(2)}ms from the UnMarsh transaction)` : `(${(match.timeDiffNs / 1e6).toFixed(2)}ms from its buffer event)`),
|
|
15640
15801
|
drillDown
|
|
15641
15802
|
});
|
|
15642
15803
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-perf/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty analyzers with provenance and fidelity, reports and a scenario runner",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"harmonyos",
|