As an optimization for some Win64 code, I reserve 4 GB of address space and then commit a certain amount of MB (for example, 512 MB) in this address space (which ultimately gives huge performance to improve the removal of array bindings, but this is all close to point). The code that I have basically looks like this:
LPVOID address = VirtualAlloc(null, FOUR_GB, MEM_RESERVE, PAGE_NOACCESS); arrayAddress = VirtualAlloc(address, length, MEM_COMMIT, PAGE_READWRITE);
Someone on my team recently read an article on large pages that require fewer TLB requests and have significant performance improvements in some scenarios, and this seemed like a simple candidate for this.
However, what I'm reading makes me think that maybe this will not work. MSDN says that "size and alignment must be a multiple of the minimum on a large page." I can easily make sure that the length is a multiple of the minimum on the large page, but how can I do this for alignment? If I can pass the MEM_LARGE_PAGES flag to the reservation, I assume that it will align it correctly. But I read that you cannot call VirtualAlloc with MEM_RESERVE | MEM_LARGE_PAGES.
So, I think that I can do what I am doing now, but VirtualAlloc with FOUR_GB + GetLargePageMinimum () during the backup, and then align the address with GetLargePageMinimum () when committed, but this does not suit me.
Does anyone know how to do this correctly?
source share