Wednesday, March 11, 2009

FreeBSD - NGROUPS_MAX

(http://antbsd.twbbs.org/~ant/wordpress/?p=100, March 26th, 2006)

最近因為單位機器需求,須把 FreeBSD 中對每位 user 參與的 group 上限放寬。FreeBSD 預設允許每位 user 參與 15 (小於 16) 個 group。修改的檔案在 /usr/src/sys/sys/syslimits.h。

#define NGROUPS_MAX 16 /* max supplemental group id’s */

把 16 直接改成需要的數字,然後重編 kernel 就可以了。

去查了一下原因,發現是因為效能的關係。小於 16 的變數是固定長度變數,因此耗的 kernel memory 較少,而當超越此值時,會變成可變變數(variable-length),超會耗很多的 kernel memory。

參考此文http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2005-05/1086.html

If you need a large potential increase in maximum groups, you need to move to a variable-length credential structure so you don’t waste lots of kernel memory. I have an initial prototype of this in some branch in Perforce. Basically, if you ask for <16 groups, you just get groups in ucred, otherwise you get an extended storage allocation that contains a ucred. Among other things, you now have to also maintain an array size. I

No comments:

Post a Comment