[OT] PrefetchVirtualMemory() questions,...

Hi,

not a driver question, but here are the right people to ask! I have a few questiosn regarding the new PrefetchVirtualMemory() function starting its availability with Windows 8. Currently i dont have a system to investiagte on the function :frowning:

http://msdn.microsoft.com/en-us/library/hh780543(VS.85).aspx

I guess this function can be really of use for applications that will do some read-ahead prefetching of memory that will (possibly) be “used” in some way on later usage. As the documentation says, there can be advantages on it, so that the “function can provide performance improvements by issuing a single large I/O rather than the many smaller I/Os that would be issued via page faulting”. From here all is clear to me so far. But here are my questions i would politely like to ask:

The documentation says: “The prefetched memory is not added to the target process’ working set; it is cached in physical memory”

  • Does this block of memory have some “expiration date” where it will possibly be freed/invalided since its not really used and touched in some way, just staying ready to be used, or do the well know rules of windows memory management work here? What exactly is meant by “physical memory”? Is it real physical memory, or does this include pagefile paged-out memory as well? Will the cached memory be paged at some point. e.g. more memory needed? Can this cached memory be freed manually in some way? Is this memory shared in some way among processes/windows so other processes can use a “copy” of it without doing e.g. a disk/media hardware access or is it only accessible for the calling process?

Again the documentations says: “…and is subject to usual physical memory constraints where it can completely or partially fail under low-memory conditions. It can also create memory pressure if called with large address ranges,…”

  • What exactly is meant by “partially fail”? Does this mean the function will fail at some point and return some error code (possibly a 299/0x12b) and stop processing the VirtualAddresses-Array passed to the function, or will it skip the “failed” parts/addresses passed with the VirtualAddresses-Array parameter and keep on processing the array elements until its finished? WIll it then possibly return something like 299/0x12b? What happens if the function hits a PAGE_NOACCESS or PAGE_GUARD protected memory block passed in the VirtualAddresses-Array?

Thanks in advance…

K.

Quickly reading the documentation, I would guess that this turns hard faults
into soft faults by signalling for some kind of prefetch by the memory
manger. This would be useful for programs using memory mapped files where
there is abundant RAM

wrote in message news:xxxxx@ntdev…

Hi,

not a driver question, but here are the right people to ask! I have a few
questiosn regarding the new PrefetchVirtualMemory() function starting its
availability with Windows 8. Currently i dont have a system to investiagte
on the function :frowning:

http://msdn.microsoft.com/en-us/library/hh780543(VS.85).aspx

I guess this function can be really of use for applications that will do
some read-ahead prefetching of memory that will (possibly) be “used” in some
way on later usage. As the documentation says, there can be advantages on
it, so that the “function can provide performance improvements by issuing a
single large I/O rather than the many smaller I/Os that would be issued via
page faulting”. From here all is clear to me so far. But here are my
questions i would politely like to ask:

The documentation says: “The prefetched memory is not added to the target
process’ working set; it is cached in physical memory”

  • Does this block of memory have some “expiration date” where it will
    possibly be freed/invalided since its not really used and touched in some
    way, just staying ready to be used, or do the well know rules of windows
    memory management work here? What exactly is meant by “physical memory”? Is
    it real physical memory, or does this include pagefile paged-out memory as
    well? Will the cached memory be paged at some point. e.g. more memory
    needed? Can this cached memory be freed manually in some way? Is this memory
    shared in some way among processes/windows so other processes can use a
    “copy” of it without doing e.g. a disk/media hardware access or is it only
    accessible for the calling process?

Again the documentations says: “…and is subject to usual physical memory
constraints where it can completely or partially fail under low-memory
conditions. It can also create memory pressure if called with large address
ranges,…”

  • What exactly is meant by “partially fail”? Does this mean the function
    will fail at some point and return some error code (possibly a 299/0x12b)
    and stop processing the VirtualAddresses-Array passed to the function, or
    will it skip the “failed” parts/addresses passed with the
    VirtualAddresses-Array parameter and keep on processing the array elements
    until its finished? WIll it then possibly return something like 299/0x12b?
    What happens if the function hits a PAGE_NOACCESS or PAGE_GUARD protected
    memory block passed in the VirtualAddresses-Array?

Thanks in advance…

K.

Prefetching memory is a well researched technique, for getting the
memory before it is needed, taking advantage of parallelism since a
typical page fault blocks the thread till the fault is complete. There
are compilers who have optimizations for this even. The partial fail in
most research relates to the fact that not all pages may be pulled in,
so you could still get a hard page fault.

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@arcor.de” wrote in message
news:xxxxx@ntdev:

> Hi,
>
> not a driver question, but here are the right people to ask! I have a few questiosn regarding the new PrefetchVirtualMemory() function starting its availability with Windows 8. Currently i dont have a system to investiagte on the function :frowning:
>
> http://msdn.microsoft.com/en-us/library/hh780543(VS.85).aspx
>
> I guess this function can be really of use for applications that will do some read-ahead prefetching of memory that will (possibly) be “used” in some way on later usage. As the documentation says, there can be advantages on it, so that the “function can provide performance improvements by issuing a single large I/O rather than the many smaller I/Os that would be issued via page faulting”. From here all is clear to me so far. But here are my questions i would politely like to ask:
>
> The documentation says: “The prefetched memory is not added to the target process’ working set; it is cached in physical memory”
>
> - Does this block of memory have some “expiration date” where it will possibly be freed/invalided since its not really used and touched in some way, just staying ready to be used, or do the well know rules of windows memory management work here? What exactly is meant by “physical memory”? Is it real physical memory, or does this include pagefile paged-out memory as well? Will the cached memory be paged at some point. e.g. more memory needed? Can this cached memory be freed manually in some way? Is this memory shared in some way among processes/windows so other processes can use a “copy” of it without doing e.g. a disk/media hardware access or is it only accessible for the calling process?
>
> Again the documentations says: “…and is subject to usual physical memory constraints where it can completely or partially fail under low-memory conditions. It can also create memory pressure if called with large address ranges,…”
>
> - What exactly is meant by “partially fail”? Does this mean the function will fail at some point and return some error code (possibly a 299/0x12b) and stop processing the VirtualAddresses-Array passed to the function, or will it skip the “failed” parts/addresses passed with the VirtualAddresses-Array parameter and keep on processing the array elements until its finished? WIll it then possibly return something like 299/0x12b? What happens if the function hits a PAGE_NOACCESS or PAGE_GUARD protected memory block passed in the VirtualAddresses-Array?
>
> Thanks in advance…
>
> K.

The documentation is intentionally vague on most of these points because it describes the contract, not the implementation.

The current implementation puts pages on the standby list (after which normal memory management policies apply). A future implementation could do something different.

All of the failure modes you listed below are allowed. With regard to no access or guard pages, the best practice is to not try to prefetch those. Since you’re going to access the pages soon, you can first make them accessible and then prefetch.


From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] on behalf of xxxxx@arcor.de [xxxxx@arcor.de]
Sent: Friday, June 15, 2012 10:30 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] [OT] PrefetchVirtualMemory() questions,…

Hi,

not a driver question, but here are the right people to ask! I have a few questiosn regarding the new PrefetchVirtualMemory() function starting its availability with Windows 8. Currently i dont have a system to investiagte on the function :frowning:

http://msdn.microsoft.com/en-us/library/hh780543(VS.85).aspx

I guess this function can be really of use for applications that will do some read-ahead prefetching of memory that will (possibly) be “used” in some way on later usage. As the documentation says, there can be advantages on it, so that the “function can provide performance improvements by issuing a single large I/O rather than the many smaller I/Os that would be issued via page faulting”. From here all is clear to me so far. But here are my questions i would politely like to ask:

The documentation says: “The prefetched memory is not added to the target process’ working set; it is cached in physical memory”

  • Does this block of memory have some “expiration date” where it will possibly be freed/invalided since its not really used and touched in some way, just staying ready to be used, or do the well know rules of windows memory management work here? What exactly is meant by “physical memory”? Is it real physical memory, or does this include pagefile paged-out memory as well? Will the cached memory be paged at some point. e.g. more memory needed? Can this cached memory be freed manually in some way? Is this memory shared in some way among processes/windows so other processes can use a “copy” of it without doing e.g. a disk/media hardware access or is it only accessible for the calling process?

Again the documentations says: “…and is subject to usual physical memory constraints where it can completely or partially fail under low-memory conditions. It can also create memory pressure if called with large address ranges,…”

  • What exactly is meant by “partially fail”? Does this mean the function will fail at some point and return some error code (possibly a 299/0x12b) and stop processing the VirtualAddresses-Array passed to the function, or will it skip the “failed” parts/addresses passed with the VirtualAddresses-Array parameter and keep on processing the array elements until its finished? WIll it then possibly return something like 299/0x12b? What happens if the function hits a PAGE_NOACCESS or PAGE_GUARD protected memory block passed in the VirtualAddresses-Array?

Thanks in advance…

K.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer