In my recent post about physical memory consumed by page tables when hugepages are not in use I showed an example of 500 dedicated connections to an Oracle Database 11g instance with 8000M SGA consuming roughly 7 gigabytes of physical memory just for page tables. A reader emailed me to point out that it would be informational to show page table consumption with hugepages employed. How right.
The following script was running while I invoked sqlplus 500 times to connect to the same instance discussed in this post. As the script shows, page table cost peaked at roughly 265 MB compared to the 7 GB lost to page tables in the non-hugepages case.
I’m scratching my head and thinking of what else could possibly be said on the matter…
$ while true > do > ps -ef | grep oracletest | wc -l > grep PageTables /proc/meminfo > sleep 30 > done 1 PageTables: 23484 kB 501 PageTables: 264432 kB 501 PageTables: 264900 kB 501 PageTables: 265400 kB 501 PageTables: 265944 kB 130 PageTables: 83112 kB 120 PageTables: 78672 kB 110 PageTables: 74188 kB 100 PageTables: 69712 kB 90 PageTables: 65264 kB 80 PageTables: 60804 kB 70 PageTables: 56332 kB 60 PageTables: 51872 kB 50 PageTables: 47376 kB 40 PageTables: 42848 kB 30 PageTables: 37904 kB 20 PageTables: 32976 kB 10 PageTables: 28024 kB 1 PageTables: 23532 kB 1 PageTables: 23528 kB
So it does not keep the page table memory allocated after the process has quit.
Oh BTW, I pointed to your numbers here:
http://stackoverflow.com/questions/853736/how-to-find-or-calculate-a-linux-processs-page-table-size-and-other-kernel-accou/1182989
Bernd
In our db machine,
everytime when the db startup ,the HugePages_Rsvd may increased.
Now it is 5963,and can not to release and cant not used by oracle.
Only todo is reboot machine to release it.
Are their other method to decrease it except reboot ?
thanks a bunch!
[root@dgpubdb3 ~]# cat /proc/meminfo
MemTotal: 32959992 kB
MemFree: 10257644 kB
Buffers: 137896 kB
Cached: 9728592 kB
SwapCached: 159328 kB
Active: 8431064 kB
Inactive: 1781244 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 32959992 kB
LowFree: 10257644 kB
SwapTotal: 16386292 kB
SwapFree: 13313700 kB
Dirty: 96 kB
Writeback: 0 kB
AnonPages: 186480 kB
Mapped: 2391716 kB
Slab: 134276 kB
PageTables: 80524 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 26760176 kB
Committed_AS: 16327048 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 271316 kB
VmallocChunk: 34359466727 kB
HugePages_Total: 5963
HugePages_Free: 5963
HugePages_Rsvd: 5963
Hugepagesize: 2048 kB
Yafang,
What does the output of ipcs -m look like? Also, I presume there are no other apps on the box calling shmget with the SHM_HUGETLB (or no usage of hugetlbfs/libhugetlbfs for that matter). The pages are only in reserved status until processes attached to the segment start to fault the pages in. If you set the init.ora parameter pre_page_sga to TRUE you should notice that the pages come out of reserved and are deducted from HugePages_Free as soon as the instance boot process is complete.
If the hugepages are not being used by Oracle it is probably because it is an insufficient amount (as I blogged about). So, what does show sga report? You might care to run the sizing script.
this machine only run oracle database.
I has not set parameter “pre_page_sga”
The problem is HugePages_Rsvd always increase when ths db startup.
when you shutdown db,HugePages_Rsvd is not retrun to zero.
when it increase to a number,the Hugepage that can allocated for sga less than SGA,then the SGA can not use Hugepage at all and the HugePages_Rsvd can reach a very high value ,as 5963 in example.
This memory(5963*2MB) can not release to system.
Only reboot can free the reserved Hugepage and use Hugepage normally.
But if you shutdown db and restart,maybe can not use Hugepage and HugePages_Rsvd*2MB amount memory is wasted ,can not use by any application,and can not relesed to system until reboot.
Thanks for your response.
I like your blog.
if you have no ipc segs (ipcs -m) and you echo 0 > /proc/sys/vm/nr_hugepages it should certainly clear
thanks for the information Kevin. I have been testing huge pages and noticed the page table size differences as well, on a 2 node NUMA configured IBM3950 with 256GB memory, without huge pages the page table can really expand under load. Overall I am seeing 10% or greater performance gains on several platforms for SGA sizes 6G and 10G for my test databases.
…thanks for stopping by, Steve
Hi Kevin,
I’ve given a presentation on Oracle and memory a few times. I talk a lot about hugepages there.
Slides with synced audio can be found here:
http://www.pythian.com/news/741/pythian-goodies-free-memory-swap-oracle-and-everything
Hello Kevin,
First, thanks for this series of posts on Hugepages with detail explanations and test cases.
However, I have a doubt about the test case used above. In your test case, you are only creating DB sessions (in dedicated server mode) but those DB sessions do nothing (and in particular do not “use” SGA). In that case, how does using/not using HugePgaes help? Are Hugepages used by SGA as well as PGA or only SGA?
Thanks
“you are only creating DB sessions (in dedicated server mode) but those DB sessions do nothing (and in particular do not “use” SGA).”
Hello Narenda,
If you get a session via a dedicated connection your foreground process maps the entire SGA–immediately. That is sufficient use to see the cost in page tables as I show via meminfo in the post.
Hello Kevin,
Thanks for your response.
Apologies if this sounds like a naive question but what exactly does it mean by “foreground process maps the entire SGA-immediately.” ? If process “mapping” memory does not mean process “using” memory, why would page tables be need to contain details about it?
Mapping memory is using memory. You get page table entries immediately and that has cost.