gpt4 book ai didi

c++ - Windows 7/64 上的 VirtualAllocExNuma 内存访问时间变慢

转载 作者:可可西里 更新时间:2023-11-01 18:35:05 25 4
gpt4 key购买 nike

在我们的应用程序中,我们在双 Xeon 服务器上运行,每个处理器的本地内存配置为 12 GB,内存总线连接两个 Xeon。出于性能原因,我们希望控制在何处分配大(>6gb)内存块。下面是简化的代码-

DWORD processorNumber = GetCurrentProcessorNumber();
UCHAR nodeNumber = 255;
GetNumaProcessorNode((UCHAR)processorNumber, &nodeNumber );
// get amount of physical memory available of node.
ULONGLONG availableMemory = MAXLONGLONG;
GetNumaAvailableMemoryNode(nodeNumber, &availableMemory )
// make sure that we don't request too much. Initial limit will be 75% of available memory
_allocateAmt = qMin(requestedMemory, availableMemory * 3 / 4);
// allocate the cached memory region now.
HANDLE handle = (HANDLE)GetCurrentProcess ();
cacheObject = (char*) VirtualAllocExNuma (handle, 0, _allocateAmt,
MEM_COMMIT | MEM_RESERVE ,
PAGE_READWRITE| PAGE_NOCACHE , nodeNumber);

原样的代码在 Win 7/64 上使用 VS2008 可以正常工作。

在我们的应用程序中,这 block 内存用作通常存储在硬盘驱动器上的静态对象 (1-2mb ea) 的缓存存储。我的问题是,当我们使用 memcpy 将数据传输到缓存区域时,它花费的时间比我们使用 new char[xxxx] 分配内存的时间长 10 倍以上。并且没有其他代码更改。

我们无法理解为什么会发生这种情况。关于在哪里查看有什么建议吗?

最佳答案

PAGE_NOCACHE 是对 perf 的谋杀,它禁用了 CPU 缓存。这是故意的吗?

关于c++ - Windows 7/64 上的 VirtualAllocExNuma 内存访问时间变慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3763351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com