KeInsertQueueDpc的高CPU使用率

时间:2017-10-16 00:52:31

标签: multithreading winapi kernel profiling driver

我的多线程程序,尽管运行尽可能多的线程,但仍然没有使用100%的CPU(我设法将其提高到大约90-95%)。也许这是由于到目前为止需要一些单线程阶段。

我尝试使用CodeXL进行配置(基于时间的采样,为在用户和内核模式下执行的代码收集),它显示的前2个功能确实是多线程代码中的瓶颈。但是,这2个函数仅占样本的84.87%。

还有KeInsertQueueDpc需要8.03%的时间。总共为92.9%。剩余的7.1%似乎分散在许多(数百个)不经常调用的函数中。

我已经阅读了KeInsertQueueDpc:似乎有些延迟执行硬件中断处理程序。 CodeXL不会在调用图中显示它 - 仅在函数列表中显示。因此,我不确定程序中的哪些内容可能导致此过程导致高CPU使用率。你能建议吗?

你能否建议如何在每个功能中花费挂钟时间,而不是CPU占用时间? (如果我还没有得到这个)

如果有人想深入挖掘,这里是剖析结果(顶部函数): enter image description here 这是源代码:https://github.com/srogatch/ProbQA

更新:在下面的文字中添加了分析结果

Function    Module  Timer   Timer Percentage
ProbQA::CEEvalQsSubtaskConsider<class SRPlat::SRDoubleNumber>::Run(void)    PqaCore.dll 156376  56.4300003
SRPlat::SRVectMath::Log2Hot(struct __m256d) SRPlatform.dll  78818   28.4400005
KeInsertQueueDpc    ntoskrnl.exe    22260   8.02999973
RtlSleepConditionVariableCS ntdll.dll   1591    0.569999993
KeQueryPerformanceCounter   hal.dll 1312    0.469999999
RtlEnterCriticalSection ntdll.dll   977 0.349999994
KeWaitForMutexObject    ntoskrnl.exe    856 0.310000002
SRPlat::SRAccumVectDbl256::GetFullSum(void) PqaCore.dll 679 0.25
RtlAvlRemoveNode    ntoskrnl.exe    524 0.189999998
KeSetEvent  ntoskrnl.exe    481 0.170000002
MSHTML.dll!0x7ff8ff9b7180   MSHTML.dll  331 0.119999997
setjmpex    ntoskrnl.exe    285 0.100000001
KeReleaseInStackQueuedSpinLock  ntoskrnl.exe    244 0.0900000036
exp2    ucrtbase.dll    231 0.0799999982
ChromeMain  chrome_child.dll    197 0.0700000003
DllCanUnloadNow MSHTML.dll  193 0.0700000003
d_int   ucrtbase.dll    175 0.0599999987
SRPlat::SRAccumulator<class SRPlat::SRDoubleNumber>::Add(class SRPlat::SRDoubleNumber)  PqaCore.dll 175 0.0599999987
MilTransport_Release    dwmcore.dll 155 0.0599999987
ObReferenceObjectByHandle   ntoskrnl.exe    151 0.0500000007
SRPlat::SRDoubleNumber::SRDoubleNumber(double)  SRPlatform.dll  133 0.0500000007
ExReleaseFastMutex  ntoskrnl.exe    120 0.0399999991
FltDecodeParameters FLTMGR.SYS  114 0.0399999991
dexp    ucrtbase.dll    111 0.0399999991
RtlAllocateHeap ntdll.dll   109 0.0399999991
ExAllocatePoolWithTag   ntoskrnl.exe    107 0.0399999991
HasHidTable win32kfull.sys  106 0.0399999991
SRPlat::BucketerSubtaskSum<class SRPlat::SRDoubleNumber>::Run(void) SRPlatform.dll  103 0.0399999991
KeIsSingleGroupAffinityEx   ntoskrnl.exe    100 0.0399999991
RtlUpcaseUnicodeChar    ntoskrnl.exe    99  0.0399999991
ProbQA::CERecordAnswerSubtaskMul<class SRPlat::SRDoubleNumber>::Run(void)   PqaCore.dll 99  0.0399999991
RtlLeaveCriticalSection ntdll.dll   89  0.0299999993
NVAPI_Thunk nvwgf2umx_cfg.dll   89  0.0299999993
ExAcquireFastMutex  ntoskrnl.exe    88  0.0299999993
ExAcquireResourceSharedLite ntoskrnl.exe    84  0.0299999993
ExAcquirePushLockSharedEx   ntoskrnl.exe    83  0.0299999993
ExFreePoolWithTag   ntoskrnl.exe    83  0.0299999993
SRPlat::SRUtils::FillZeroVects<1>(union __m256i *,unsigned __int64) SRPlatform.dll  81  0.0299999993
KeReleaseSpinLock   ntoskrnl.exe    79  0.0299999993
NtGdiPolyPatBlt win32kfull.sys  77  0.0299999993
memset  ntoskrnl.exe    77  0.0299999993
KeLowerIrql ntoskrnl.exe    76  0.0299999993
SRPlat::SRDoubleNumber::GetValue(void)  SRPlatform.dll  76  0.0299999993
DirectUI::Element::_GetDependencies(struct DirectUI::PropertyInfo const *,int,struct DirectUI::DepRecs *,int,class DirectUI::Value *,class DirectUI::DeferCycle *)  DUI70.dll   75  0.0299999993
RtlEqualSid ntoskrnl.exe    72  0.0299999993
ExpInterlockedPopEntrySList ntoskrnl.exe    71  0.0299999993
DirectUI::Element::_GetSpecifiedValue(struct DirectUI::PropertyInfo const *,struct DirectUI::UpdateCache *) DUI70.dll   71  0.0299999993
KeExpandKernelStackAndCalloutEx ntoskrnl.exe    70  0.0299999993
IofCallDriver   ntoskrnl.exe    69  0.0199999996
TurboDispatchJumpAddressEnd wow64cpu.dll    68  0.0199999996
SRPlat::SRThreadPool::WorkerEntry(void) SRPlatform.dll  65  0.0199999996
GetWebPlatformObject    MSHTML.dll  60  0.0199999996
KeClearEvent    ntoskrnl.exe    58  0.0199999996
NtDeviceIoControlFile   ntoskrnl.exe    58  0.0199999996
ExReleaseResourceLite   ntoskrnl.exe    56  0.0199999996
FltIsCallbackDataDirty  Unknown Module (PID 10248)  54  0.0199999996
KeReleaseMutex  ntoskrnl.exe    54  0.0199999996
ExAcquireRundownProtectionCacheAwareEx  ntoskrnl.exe    54  0.0199999996
SeLockSubjectContext    ntoskrnl.exe    53  0.0199999996
PcwAddInstance  ntoskrnl.exe    52  0.0199999996
RtlRetrieveNtUserPfn    ntdll.dll   52  0.0199999996
d3d10warp.dll!0x7ff92812f080    d3d10warp.dll   52  0.0199999996
PPP_ShutdownBroker  pepflashplayer.dll  51  0.0199999996
dtest   ucrtbase.dll    48  0.0199999996
IofCompleteRequest  ntoskrnl.exe    47  0.0199999996
RtlSleepConditionVariableSRW    ntdll.dll   46  0.0199999996
FltGetStreamContext Unknown Module (PID 10248)  45  0.0199999996
PyEval_EvalFrameEx  python27.dll    45  0.0199999996
nvlddmkm.sys!0xf800123f9465 nvlddmkm.sys    44  0.0199999996
SeAccessCheckWithHint   ntoskrnl.exe    44  0.0199999996
IsSandboxedProcess  slack.exe   43  0.0199999996
SRPlat::SRAccumVectDbl256::Add(unsigned char,double)    PqaCore.dll 42  0.0199999996
GetHandleVerifier   chrome_child.dll    42  0.0199999996
FltCbdqRemoveNextIo FLTMGR.SYS  41  0.00999999978
jscript9.dll!0x7ff90739aab3 jscript9.dll    40  0.00999999978
GetHandleVerifier   slack.exe   40  0.00999999978
ExReleaseRundownProtectionCacheAware    ntoskrnl.exe    38  0.00999999978
RtlCopyMemory   ntoskrnl.exe    38  0.00999999978
RtlFreeHeap ntdll.dll   38  0.00999999978
ExReleasePushLockEx ntoskrnl.exe    37  0.00999999978
RtlCopyMemoryNonTemporal    ntoskrnl.exe    36  0.00999999978
GetTextCharacterExtra   gdi32full.dll   36  0.00999999978
ExReleaseCacheAwarePushLockSharedEx ntoskrnl.exe    35  0.00999999978
MSHTML.dll!0x7ff8ffc5ee30   MSHTML.dll  35  0.00999999978
PsReturnProcessPagedPoolQuota   ntoskrnl.exe    34  0.00999999978
xxxWindowEvent  win32kfull.sys  33  0.00999999978
CcCopyReadEx    ntoskrnl.exe    33  0.00999999978
ExAcquireCacheAwarePushLockSharedEx ntoskrnl.exe    33  0.00999999978
EngBitBlt   win32kfull.sys  31  0.00999999978
v8::internal::IncrementalMarking::RecordWriteSlow(class v8::internal::HeapObject *,class v8::internal::Object * *,class v8::internal::Object *) node.dll    31  0.00999999978
MmUnlockPages   ntoskrnl.exe    30  0.00999999978
ExAcquirePushLockExclusiveEx    ntoskrnl.exe    30  0.00999999978
avgSP.sys!0xf80710a723e9    avgSP.sys   29  0.00999999978
ObReferenceObjectSafeWithTag    ntoskrnl.exe    29  0.00999999978
ProbQA::CEHeapifyPriorsSubtaskMake<class SRPlat::SRDoubleNumber>::Run(void) PqaCore.dll 29  0.00999999978
PsReturnProcessNonPagedPoolQuota    ntoskrnl.exe    28  0.00999999978
ExReleaseRundownProtectionCacheAwareEx  ntoskrnl.exe    28  0.00999999978
RtlCmEncodeMemIoResource    ntoskrnl.exe    28  0.00999999978
DirectUI::Element::_PreSourceChange(struct DirectUI::PropertyInfo const *,int,class DirectUI::Value *,class DirectUI::Value *)  DUI70.dll   28  0.00999999978
MmProbeAndLockPages ntoskrnl.exe    27  0.00999999978
ExReleaseResourceAndLeaveCriticalRegion ntoskrnl.exe    27  0.00999999978
RtlEnumerateGenericTableWithoutSplayingAvl  ntoskrnl.exe    26  0.00999999978
Tcpip6_WSHOpenSocket2   mswsock.dll 26  0.00999999978
ovly_debug_event    chrome_child.dll    25  0.00999999978
dscale  ucrtbase.dll    24  0.00999999978
RtlAllocateHeap ntdll.dll   24  0.00999999978
IsSandboxedProcess  chrome_child.dll    24  0.00999999978
NtUserCallNextHookEx    win32kfull.sys  23  0.00999999978
RtlInitializeCriticalSectionEx  ntdll.dll   23  0.00999999978
D2D1MakeSkewMatrix  d2d1.dll    23  0.00999999978
v8::internal::StoreBuffer::StoreBufferOverflow(class v8::internal::Isolate *)   node.dll    23  0.00999999978
ObfDereferenceObjectWithTag ntoskrnl.exe    22  0.00999999978
MmMapLockedPagesSpecifyCache    ntoskrnl.exe    22  0.00999999978
D2D1IsMatrixInvertible  d2d1.dll    22  0.00999999978
KeWaitForMultipleObjects    ntoskrnl.exe    21  0.00999999978
RtlFindNextForwardRunClearCapped    ntoskrnl.exe    21  0.00999999978
NtWriteFile ntoskrnl.exe    21  0.00999999978
memcpy  msvcrt.dll  21  0.00999999978
NtWaitForAlertByThreadId    ntdll.dll   20  0.00999999978
memset  msvcrt.dll  20  0.00999999978
ObOpenObjectByNameEx    ntoskrnl.exe    19  0.00999999978
MetaDataGetDispenser    clr.dll 19  0.00999999978
SleepEx KernelBase.dll  19  0.00999999978
DirectUI::Element::FindDescendentWorker(unsigned short) DUI70.dll   19  0.00999999978
SetGadgetStyle  DUser.dll   19  0.00999999978
DefragOpenVolume    PDEngine.exe    19  0.00999999978
FltObjectReference  FLTMGR.SYS  18  0.00999999978
CcCoherencyFlushAndPurgeCache   ntoskrnl.exe    18  0.00999999978
RtlEnterCriticalSection ntdll.dll   18  0.00999999978
avgSP.sys!0xf80710a56cc7    avgSP.sys   17  0.00999999978
NtUserScrollDC  win32kfull.sys  17  0.00999999978
MmMapIoSpaceEx  ntoskrnl.exe    17  0.00999999978
KeEnterCriticalRegion   ntoskrnl.exe    17  0.00999999978
IoStartPacket   ntoskrnl.exe    17  0.00999999978
WaitForMultipleObjectsEx    KernelBase.dll  17  0.00999999978
PyDict_Fini python27.dll    17  0.00999999978
mshtml.dll!0x62e7bfc0   mshtml.dll  17  0.00999999978
DirectUI::VerticalFlowLayout::UpdateDesiredSize(class DirectUI::Element *,int,int,class DirectUI::Surface *)    DUI70.dll   17  0.00999999978
OpenAdapter12   nvwgf2umx_cfg.dll   17  0.00999999978
FltGetInstanceContext   FLTMGR.SYS  16  0.00999999978
CcCopyWriteEx   ntoskrnl.exe    16  0.00999999978
KeSynchronizeExecution  ntoskrnl.exe    16  0.00999999978
NtQueryInformationFile  ntoskrnl.exe    16  0.00999999978
FsRtlReleaseFile    ntoskrnl.exe    16  0.00999999978
PsLookupProcessByProcessId  ntoskrnl.exe    16  0.00999999978
WaitForSingleObjectEx   KernelBase.dll  16  0.00999999978
KeRemoveQueueEx ntoskrnl.exe    15  0.00999999978
ExEnterCriticalRegionAndAcquireResourceExclusive    ntoskrnl.exe    15  0.00999999978
KeEnterGuardedRegion    ntoskrnl.exe    15  0.00999999978
qsort   msvcrt.dll  15  0.00999999978
FlsGetValue KernelBase.dll  15  0.00999999978
BTCpuResetToConsistentState wow64cpu.dll    15  0.00999999978
Wow64SystemServiceEx    wow64.dll   15  0.00999999978
PyEval_GetGlobals   python27.dll    15  0.00999999978
CoUninitializeEE    clr.dll 15  0.00999999978
SetRuntimeInfo  clr.dll 15  0.00999999978
ANGLEResetDisplayPlatform   libglesv2.dll   15  0.00999999978
HmgLockEx   win32kbase.sys  14  0.00999999978
NtUserDispatchMessage   win32kfull.sys  14  0.00999999978
ObfDereferenceObject    ntoskrnl.exe    14  0.00999999978
MmDoesFileHaveUserWritableReferences    ntoskrnl.exe    14  0.00999999978
MmChangeImageProtection ntoskrnl.exe    14  0.00999999978
NtQuerySystemInformation    ntoskrnl.exe    14  0.00999999978
RtlWakeAllConditionVariable ntdll.dll   14  0.00999999978
SRPlat::SRBaseTask::FinalizeSubtask(class SRPlat::SRBaseSubtask *)  SRPlatform.dll  14  0.00999999978
UninitializeLocalHtmlEngine MSHTML.dll  14  0.00999999978
DirectUI::Element::_GetLocalValue(struct DirectUI::PropertyInfo const *)    DUI70.dll   14  0.00999999978
MilTransport_AddRef dwmcore.dll 14  0.00999999978

0 个答案:

没有答案