linux oracle/jdk启用大页面

  大页的优点在于可以使得堆常驻内存,不会被交换到磁盘。其次,OS管理的页面数大大减少,对于20GB内存来说,4K页面需要5,242,880个页面,2MB的话只需要10,240,相当于前者的99.8%,所以操作系统负载会大大降低。

  大多数测试大页面发现对于eden区的GC可以大大提升性能(不过大都基于JDK 1.5-1.7测试居多)。LZ做了简单的测试:

复制代码
    private static void testEdenGc() {
        try {
            Thread.sleep(15000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        UUID uuid = UUID.randomUUID();
        for (int f=0;f<10;f++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    long res = 0;
                    for (int i = 0; i < 100; i++) {
                        Map<String, Object> bigMap = new HashMap();
                        for (int x = 0; x < 100000; x++) {
                            bigMap.put(uuid.toString() + uuid.toString() + uuid.toString() + uuid.toString(), uuid);
                        }
                        res = res + bigMap.size();
                    }
                }
            }).start();
        }
    }
复制代码

大页面模式:

[root@hs-test-10-20-30-16 ~]# time java -Xms3000m -Xmx3000m -XX:+UseLargePages -XX:LargePageSizeInBytes=4m -cp . com.hundsun.ta.base.service.CompletionServiceTest
Java HotSpot(TM) 64-Bit Server VM warning: Setting LargePageSizeInBytes has no effect on this OS. Large page size is 2048K.  # 在Linux下大页面大小由os决定,而非参数决定。

real 1m21.333s
user 10m20.109s
sys 0m1.539s

普通页面模式:

[root@hs-test-10-20-30-16 ~]# time java -Xms3000m -Xmx3000m -cp . com.hundsun.ta.base.service.CompletionServiceTest

real 1m12.794s
user 8m58.983s
sys 0m1.694s

在centos 6.5下使用jdk 1.8u191测试,各自重复运行了三次,依然是普通页面比大页面快10%以上。由此可见,大页面并不总是可以提高性能。当然也可能场景过于简单。

但是openj9下,启用大页面则比不启用大页面要快10%。

除了linux,windows下也支持大页面的,可参见如下:

由于LZ环境不会使用windows作为server,故有兴趣同学可以自行测试。

参考:

https://oracle-base.com/articles/linux/configuring-huge-pages-for-oracle-on-linux-64#configuring-1g-hugepagesize

https://www.iteye.com/blog/agapple-809707

https://www.oracle.com/technetwork/java/javase/tech/largememory-jsp-137182.html

https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html/performance_tuning_guide/sect-performance_tuning_guide-java_virtual_machine_tuning-large_page_memory

posted @   zhjh256  阅读(570)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2019-01-31 redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的管道 (Write failed)
点击右上角即可分享
微信分享提示