why the page size of OS is 4k, and why it still stick to be 4k as the memory can be large enough now?
Asked Answered
P

1

12

As far as i know, the page size is 4k in OS memory management. It can be a advantage when the memory is too small. But the memory in our machine is big enough now, why the page size is still 4k? What is the limit for change it to be like 1M or bigger?

Pyromagnetic answered 7/6, 2013 at 5:1 Comment(3)
Pages are the units of swapping to/from disk. So making pages bigger would make swapping slower.Artis
What is your practical programming question? Do you want to change the page size?Shaman
As far as i know the purpose of introducing the concept of page into memory management is to support bigger program with smaller memory. The 4K size is a kind of empirical value. My discussion background is that the memory of server-machine is big enough now, and the memory used by each program is getting bigger and bigger. Should the OS changing the size of page bigger?Pyromagnetic
K
16

4KB is just default page size supported by many architectures.

However, some architectures support switching to use bigger page sizes. For example, i386 supports switching to huge pages mode with 2MB or 4MB page size, and x86_64 supports 2MB huge pages, and for some newer CPUs it can even support 1GB page size (large pages).

Many filesystems use block size that is exact page size or small multiplier of it (4KB-8KB or so). Also, many operating systems allocate memory only in whole pages. Allocating 2MB page on every memory allocation request would waste a lot of memory.

Kumasi answered 7/6, 2013 at 5:10 Comment(3)
As you said, "allocating 2MB page on every memory allocation request would waste a lot of memory", but if the program need to deal with a lots of data 'randomly', say 500G,the TLB miss will be the bottle of the performance.Pyromagnetic
I know some CPUs have supported the variable size of page, but it is not the main trend. What is the exactly limit for using 2M page at least?Pyromagnetic
There is speed boost from using big pages, but it is just few percent. According to wiki, it may increase speed by as much as 15%, depending on the application and the allocation size. 15% is an improvement, but not very largeKumasi

© 2022 - 2024 — McMap. All rights reserved.