hbase mlockall


mlockall

头文件:#include <sys/mman.h>

函数原型:int mlockall(int flags);

flags:

      MCL_CURRENT ——Lock all pages which are currently mapped into the address space of the process.
      MCL_FUTURE ——— Lock all pages which will become mapped into the address space of the process in the future. These could be for instance new pages required by a growing heap and stack as well as new memory mapped files or shared memory regions.

返回值:
  成功:返回0;
  错误:返回-1,errno被设置。

该函数的功能:
     将进程使用的部分或者全部的地址空间锁定在物理内存中,防止其被交换到swap空间。
     有些对时间敏感的应用会希望全部使用物理内存,以提高数据访问和操作的效率。

HBase中使用该功能:
   mlockall_agent VM是一个简单的代理,允许锁的地址空间的过程。这避免了在压力下进程的内存回收。
  一个例子是当regionserver的服务器运行在同一台机器上和一些使用mapreduce任务中,一些未使用的数据在该地区的服务器可能会交换,这影响服务器性能。
      在hbase-env.sh中添加:(并且JVM必须是在root用户下运行)

     export HBASE_REGIONSERVER_OPTS="-agentpath:./libmlockall_agent.so=user=hbase"

posted on 2013-12-28 22:18  代码王子  阅读(341)  评论(0编辑  收藏  举报

导航