Ejemplo n.º 1
0
        public override void MaybePrefetchMemory(List <long> pagesToPrefetch)
        {
            if (PlatformDetails.CanPrefetch == false)
            {
                return; // not supported
            }
            if (pagesToPrefetch.Count == 0)
            {
                return;
            }

            var entries = new Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY[pagesToPrefetch.Count];

            for (int i = 0; i < entries.Length; i++)
            {
                entries[i].NumberOfBytes  = (IntPtr)(4 * Constants.Storage.PageSize);
                entries[i].VirtualAddress = AcquirePagePointer(null, pagesToPrefetch[i]);
            }

            fixed(Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY *entriesPtr = entries)
            {
                Win32MemoryMapNativeMethods.PrefetchVirtualMemory(Win32Helper.CurrentProcess,
                                                                  (UIntPtr)PagerState.AllocationInfos.Length, entriesPtr, 0);
            }
        }
Ejemplo n.º 2
0
        public override void MaybePrefetchMemory(List <long> pagesToPrefetch)
        {
            if (CanPrefetch == false)
            {
                return; // not supported
            }
            if (pagesToPrefetch.Count == 0)
            {
                return;
            }

            var entries = new Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY[pagesToPrefetch.Count];

            for (int i = 0; i < entries.Length; i++)
            {
                // We are prefetching 4 pages that with 4Kb pages is 32Kb but the idea is to really get a few consecutive pages to
                // exploit locality regardless of the page size.
                entries[i].NumberOfBytes  = (IntPtr)(4 * PageSize);
                entries[i].VirtualAddress = AcquirePagePointer(null, pagesToPrefetch[i]);
            }

            fixed(Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY *entriesPtr = entries)
            {
                Win32MemoryMapNativeMethods.PrefetchVirtualMemory(_currentProcess, (UIntPtr)PagerState.AllocationInfos.Length, entriesPtr, 0);
            }
        }
Ejemplo n.º 3
0
        public override void MaybePrefetchMemory(List<long> pagesToPrefetch)
        {
            if (CanPrefetch == false)
                return; // not supported

            if (pagesToPrefetch.Count == 0)
                return;

            var entries = new Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY[pagesToPrefetch.Count];
            for (int i = 0; i < entries.Length; i++)
            {
                entries[i].NumberOfBytes = (IntPtr)(4 * PageSize);
                entries[i].VirtualAddress = AcquirePagePointer(null, pagesToPrefetch[i]);
            }

            fixed (Win32MemoryMapNativeMethods.WIN32_MEMORY_RANGE_ENTRY* entriesPtr = entries)
            {
                Win32MemoryMapNativeMethods.PrefetchVirtualMemory(Win32NativeMethods.GetCurrentProcess(), (UIntPtr)PagerState.AllocationInfos.Length, entriesPtr, 0);
            }
        }