[前][次][番号順一覧][スレッド一覧]

ruby-changes:51046

From: normal <ko1@a...>
Date: Wed, 25 Apr 2018 05:32:06 +0900 (JST)
Subject: [ruby-changes:51046] normal:r63253 (trunk): eval.c (ruby_setup): disable THP on Linux

normal	2018-04-25 05:31:59 +0900 (Wed, 25 Apr 2018)

  New Revision: 63253

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63253

  Log:
    eval.c (ruby_setup): disable THP on Linux
    
    Transparent Huge Pages (THP) decrease the effectiveness of
    CoW-friendly GC because it decreases page granularity.  That is,
    a forked process dirtying one bit of CoW-shared memory can
    trigger a copy of a huge page (2MB on x86-64) instead of a smaller,
    standard page (4K).
    
    * eval.c (ruby_setup): disable THP on Linux
      [ruby-core:86651] [Feature #14705]

  Modified files:
    trunk/eval.c
Index: eval.c
===================================================================
--- eval.c	(revision 63252)
+++ eval.c	(revision 63253)
@@ -20,6 +20,9 @@ https://github.com/ruby/ruby/blob/trunk/eval.c#L20
 #include "mjit.h"
 #include "probes.h"
 #include "probes_helper.h"
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 
 NORETURN(void rb_raise_jump(VALUE, VALUE));
 
@@ -52,6 +55,14 @@ ruby_setup(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L55
 	return 0;
 
     ruby_init_stack((void *)&state);
+
+    /*
+     * Disable THP early before mallocs happen because we want this to
+     * affect as many future pages as possible for CoW-friendliness
+     */
+#if defined(__linux__) && defined(PR_SET_THP_DISABLE)
+    prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
+#endif
     Init_BareVM();
     Init_heap();
     Init_vm_objects();

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]