In-depth SQL Server 2000 memory management mechanism (2)

zhaozj2021-02-17  57

In-depth SQL Server 2000 memory management mechanism (2)

Http://msdn.microsoft.com/data/default.aspx?pull=/library/en-us/dnsqldev/html/sqldev_01262004.asp

Can access large addresses (Large-Address-Aware Executables)

Before Windows adds support / 3GB parameters, an application is unable to access a pointer with high-level settings. A 32-bit pointer onlys the first 31-bit address space can be accessed by the user mode application. This remaining one is not. So some smart developers are not willing to waste this bit because of other purposes. (For example: can be used to mark a pointer reference to other applications allocated data types). This / 3GB parameters Just encounter a problem, because this type of program does not conveniently distinguish between a legitimate pointer reference memory space in 2G's boundary line or less than 2G, but its high position has been used for it. Pointer. Basically, if a machine is started with / 3GB parameters, this application is unable to run. To solve this situation, Microsoft adds a new flag in the Win32 PE file Characteristics to indicate whether a program is Running the Large-Address-Aware Executables mode. When the flag is started (image_file_ila_address_aware), the 32-bit of the executable file header Characteristics field is set. By this executable header The flag, the application can imply that Windows can handle pointers with high-level settings, which will not bring any exception results. When this flag is set and supported in this way, Windows is also started through / 3GB. At this time, the operating system provides an address space that has been extended privately-free mode to the application. You can check the flag of an executable by tool, such as: Dumpbin, and ImageCFG (header dump the header of the executable). Visual C The SQL SERVR has been activated by using the flag bit_irge_address_aware, so you can use this parameter in a Windows version that supports / 3GB parameters so that the operating system returns the user memory space of SQL Server.

Note: Windows checks the image_file_ilage_address_aware flag bit when the executable is started, but ignores the DLL file. DLL code must automatically process the highly set pointer.

Physical memory extension

The Intel processor has since starting from Pentium Pro, which supports a physical memory extension (PAE) memory mapping mode. The PAE mode provides physical memory space that can access 64GB. In PAE mode, memory management unit (MMU) is still executed: Page Directory Entry Page Directory Entries (PDES) and Page Table Entry Page Table Entries (PTES), but there is a new level: Page Catalog Pointer. At the same time, in the PAE mode PDES and PTES are 64-bit (not just standard 32 bits) so that the system can map more memory space than standard conversion, because the address width of PDES and PTES mode is twice the standard. This is not just an increase in the page directory pointer table. The page directory pointer table is used to manage these large-capacity tables and indexes. Some special versions of the Windows kernel need to run in the PAE mode. This kernel integrates in Windows 2000 and later versions, in a single processor's machine, in the NTKRNLPA.exe file, in the multiprocessor's machine in the NTKRNLPAMP.EXE file. You can activate the PAE mode in the boot.ini file like an increase / 3GB and / userva parameter.

Address window extension

Windows's Address Window Extension (AWE) mechanism allows applications to access more than 4GB of physical memory. A pointer is a 32-bit integer values ​​can only be saved 0x00000000 to 0xFFFFFFFF, that can be referenced within 4GB linear memory address space, the AWE allows an application to bypass these limitations, access to all the memory by the operating system. Conceptually, AWE is not a new thing. At the beginning of computer development, operating systems and applications have used similar mechanism avoidance pointers. For example: We go back to the DOS year, and the 32-bit expansion feature is often used to allow a 16-bit program to access his own memory address space. Some special destination managers and APIs often use expansion memory and extending memory. You may remember that the product Quarterdeck QEMM-386 is often used in such a thing. A typical mechanism is to allow a pointer to access a space that exceeds itself, (such as: the address is too large in its own pointer) By allocating a window or region and the memory address that cannot be accessed by the address space that can be accessed Pass the pointer. AWE Working: You can provide a zone (window) as a segment transport area in address space that can be accessed, to transmit memory addresses that cannot be accessed in user memory space.

In order to use AWE, an application needs:

1. The assigned physical memory address can be accessed via the AllocateUserphysicalPages API function. This function requires the caller with the permissions of Lock Pages In Memory.

2. An area is created in memory space that can be accessed. The Virtualalloc API function can be mapping a mapping window that maps a physical memory.

3. Follow MapUserphysicalPages or MapUserPhysicalPagessCatter Win32 API functions to complete physical memory and virtual memory mapping.

AWE already exists in all Windows 2000 and later operating systems, even in the operating system of physical memory below 2GB, the most typical application is on the machine of 2GB or above, because this is a 32-bit The processor accesses the only way to pass the memory space below 3GB. If you activate AWE support in a SQL Server system below 3GB, the system will ignore this option simultaneously to the virtual memory manager instead. AWE memory has an interesting feature that is never exchanged with disk. You may notice that the unique AWE API program can be accessed by the memory space to be accessed as physical memory. It is exactly that: AWE memory is not interacting with the system's virtual page file interactive physical memory space.

The virtual memory window is used to cache AWE read and write requests for physical memory. So, when you configure this window, it is the only feature that can be protected is to pass to the VirtualallOc API function. Don't be surprised, this means you can't use the VirtualProtect API function to protect the modifications and access of this memory area.

Note: There is no special tool to investigate the application AWE memory usage (Task Manager, Performance Monitor, and Monitoring System, etc.) to display the number of usage of each program AWE memory. This will not use the trajectory of the amount of AWE memory, while these memory are not included in each program.

/ 3GB and AWE comparison

Increasing the ability of the user program address space, almost 50% of the application is taking memory adjustment, which is very fast and popular in the Windows memory management mechanism. And the Windows AWE memory mechanism is also very flexible and stable. Just as I said earlier, when you increase 1G user memory space, these memory is obtained by reducing the core memory space (drop from 2G to 1G). Because the operation of the core code is narrow, it is a narrow piece of the entire memory space, which is used for 2G space, which shrinks these memory space means that the internal core architecture will shrink. The most important thing is Windows to manage the physical memory table, when you shrink the core memory space to 1G, you limit the size of this table, which can only manage the maximum 16GB of physical memory. For example: If your application runs on Server with 64GB physical memory and you add / 3GB parameters when starting. You can only access 25% of the entire memory - the remaining 48GB memory spaces cannot be accessed regardless of the operating system or applications. AWE allows you to access a higher memory space than the addition / 3GB parameter. Obviously, you pass / 3GB parameters just increase the 1GB user memory space, which is only valid for applications that are automatically obtained for those large addresses, but only 1GB. And / 3GB parameters contrast, AWE can make the entire physical memory valid for the operating system and valid for applications that use the AWE WIN32 API. Therefore, AWE is more complicated and more flexible and scalable. It is not that / 3GB is better than AWE - but this does exist, such as: If you need to allocate more memory space, you can't assign (thread stack, memory lock, process plan), you Maybe it's better to find / 3GB back.

转载请注明原文地址:https://www.9cbs.com/read-29089.html

New Post(0)