G
Guest
Hi Alex. You sent me off to Intel's site concerning memory management and
your recommendation that 4k cluster sizes is optimal for the pagefile.
It took me a couple of days on Intel's site to find what I was looking for.
Intel architecture involves three memory management models and they are FLAT
MODEL, SEGMENTED MODEL and REAL ADDRESS MODE MODEL
See ftp://download.intel.com/design/Pentium4/manuals/25366514.pdf
Section 3.3
Look at chapter three, page 55 where it discusses segmented memory.
"The segment selector identifies the segment to be accessed and the offset
identifies a byte in the address pace of the segment. The programs running
on a IA-32 processor can address up to 16,383 segments of diffent sizes and
types, and each segment can be as large as 2 to the 32nd power"
See here: http://www.intel.com/design/pentiumii/manuals/24319202.pdf
Section 3.6 Paging (Virtual Memory)
Second paragraph.
“When paging is used, the processor divides the linear address space into
fixed sized paged (generally 4 Kbytes in length) that is mapped into physical
memory and/or disk storage.â€
Section 3.6.1 Paging Options
Paging is controlled by three flags in the processors control registers:
PG (paging flag)
PSE (page size extensions) flag
PAE (physical address extension)
Skipping down to the PSE description
“The PSE flag enables large page sizes: 4 Mbyte [that’s MEGAbytes] pages or
2 Mbyte pages (when the PAE flag is set)
If you look at table 3-3 you will note 4KB, 2MB and 4MB paging sizes.
This refutes the idea that paging is ONLY done in 4K incriments. It would
appear to me that the SEGMENTED memory model is used more often in XP memory
operations not the LINEAR MODEL.
The point I am making is when we discuss memory operations we talk about 4kb
pages [4096 bytes]. This is in its simplest form for discussion. This does
NOT relate to how data is written to pagefile.sys. It appears to me that an
assumption was made that since paging in RAM is done in 4k pages that any
page swapped out to disk is done in 4k incriments. I believe the above links
show that paging is NOT done exclusively by 4kb but also includes 2MB and 4MB
pages.
Now lets look at this from a disk write perspective.
You say 4kb from disk to RAM is optimal because “so that transfers may be
made direct from the file to RAM without any need for internediate
bufferingâ€. I can agree with that reasoning but reading from disk is not
done 4k at a time so you would achieve the same results if the cluster size
was 32k. What you neglect is the operation going from RAM to disk.
We know that memory operations in RAM are done in nanoseconds [billionths]
and drives are measured in milliseconds [thousandths]. From this we know
that when a disk write from memory to disk is going to take place it is not
one 4kb page that is going to be written. There is going to be a STACK of
them written to the pagefile referred to as a multiwrite request. We now
know that the “pages†can be 4kb, 2MB and 4MB. A 2MB page would occupy 512
4k clusters. That is 512 WRITES with 4k clusters. If 64K clusters that
would be done to 32 writes. It is going to take longer to write 512 times
then 32 times with the same read/write heads. 4kb clusters don’t add up as
optimal for pagefile operations. 4kb clusters DO NOT waste disk space BUT
you sacrifice SPEED. Speed is what you want to optimize for paging to disk.
Going from physical RAM to disk EVERY WRITE has to be cached!!! The write
has to wait for the disk. It’s that billionth to a thousandth time lag.
This would make pagefile write operations the slowest part of the entire
memory operation. You do not increase write speed with smaller cluster sizes
but with LARGER ones. Ideally if you knew the AVERAGE write size you would
adjust your cluster size accordingly.
The information I could not find on Intel’s or Microsoft’s web sites is how
information is written to pagefile.sys. What incremental sizes are used to
write to the pagefile. In other words, is a stack of 4k memory pages [using
your model] written as one contiguous write? When retrieved and deleted 4k
at a time how is this space recovered to provide the largest contiguous block
available to be written? After all if a 128kb of 4kb pages is written to
pagefile.sys and only 32kb are read and deleted holes in that 128kb
contiguous write block will happen.
By chance do you have any links that may answer these questions?
Another question would be are you going to continue to recommend 4kb
allocation units as optimal for paging on your web site?
your recommendation that 4k cluster sizes is optimal for the pagefile.
It took me a couple of days on Intel's site to find what I was looking for.
Intel architecture involves three memory management models and they are FLAT
MODEL, SEGMENTED MODEL and REAL ADDRESS MODE MODEL
See ftp://download.intel.com/design/Pentium4/manuals/25366514.pdf
Section 3.3
Look at chapter three, page 55 where it discusses segmented memory.
"The segment selector identifies the segment to be accessed and the offset
identifies a byte in the address pace of the segment. The programs running
on a IA-32 processor can address up to 16,383 segments of diffent sizes and
types, and each segment can be as large as 2 to the 32nd power"
See here: http://www.intel.com/design/pentiumii/manuals/24319202.pdf
Section 3.6 Paging (Virtual Memory)
Second paragraph.
“When paging is used, the processor divides the linear address space into
fixed sized paged (generally 4 Kbytes in length) that is mapped into physical
memory and/or disk storage.â€
Section 3.6.1 Paging Options
Paging is controlled by three flags in the processors control registers:
PG (paging flag)
PSE (page size extensions) flag
PAE (physical address extension)
Skipping down to the PSE description
“The PSE flag enables large page sizes: 4 Mbyte [that’s MEGAbytes] pages or
2 Mbyte pages (when the PAE flag is set)
If you look at table 3-3 you will note 4KB, 2MB and 4MB paging sizes.
This refutes the idea that paging is ONLY done in 4K incriments. It would
appear to me that the SEGMENTED memory model is used more often in XP memory
operations not the LINEAR MODEL.
The point I am making is when we discuss memory operations we talk about 4kb
pages [4096 bytes]. This is in its simplest form for discussion. This does
NOT relate to how data is written to pagefile.sys. It appears to me that an
assumption was made that since paging in RAM is done in 4k pages that any
page swapped out to disk is done in 4k incriments. I believe the above links
show that paging is NOT done exclusively by 4kb but also includes 2MB and 4MB
pages.
Now lets look at this from a disk write perspective.
You say 4kb from disk to RAM is optimal because “so that transfers may be
made direct from the file to RAM without any need for internediate
bufferingâ€. I can agree with that reasoning but reading from disk is not
done 4k at a time so you would achieve the same results if the cluster size
was 32k. What you neglect is the operation going from RAM to disk.
We know that memory operations in RAM are done in nanoseconds [billionths]
and drives are measured in milliseconds [thousandths]. From this we know
that when a disk write from memory to disk is going to take place it is not
one 4kb page that is going to be written. There is going to be a STACK of
them written to the pagefile referred to as a multiwrite request. We now
know that the “pages†can be 4kb, 2MB and 4MB. A 2MB page would occupy 512
4k clusters. That is 512 WRITES with 4k clusters. If 64K clusters that
would be done to 32 writes. It is going to take longer to write 512 times
then 32 times with the same read/write heads. 4kb clusters don’t add up as
optimal for pagefile operations. 4kb clusters DO NOT waste disk space BUT
you sacrifice SPEED. Speed is what you want to optimize for paging to disk.
Going from physical RAM to disk EVERY WRITE has to be cached!!! The write
has to wait for the disk. It’s that billionth to a thousandth time lag.
This would make pagefile write operations the slowest part of the entire
memory operation. You do not increase write speed with smaller cluster sizes
but with LARGER ones. Ideally if you knew the AVERAGE write size you would
adjust your cluster size accordingly.
The information I could not find on Intel’s or Microsoft’s web sites is how
information is written to pagefile.sys. What incremental sizes are used to
write to the pagefile. In other words, is a stack of 4k memory pages [using
your model] written as one contiguous write? When retrieved and deleted 4k
at a time how is this space recovered to provide the largest contiguous block
available to be written? After all if a 128kb of 4kb pages is written to
pagefile.sys and only 32kb are read and deleted holes in that 128kb
contiguous write block will happen.
By chance do you have any links that may answer these questions?
Another question would be are you going to continue to recommend 4kb
allocation units as optimal for paging on your web site?