作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在我们的应用程序中,我们在双 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/
在我们的应用程序中,我们在双 Xeon 服务器上运行,每个处理器的本地内存配置为 12 GB,内存总线连接两个 Xeon。出于性能原因,我们希望控制在何处分配大(>6gb)内存块。下面是简化的代码-
我是一名优秀的程序员,十分优秀!