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

ruby-changes:36097

From: normal <ko1@a...>
Date: Wed, 29 Oct 2014 03:40:06 +0900 (JST)
Subject: [ruby-changes:36097] normal:r48178 (trunk): signal.c: avoid repeated disable/enable interrupt

normal	2014-10-29 03:39:45 +0900 (Wed, 29 Oct 2014)

  New Revision: 48178

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

  Log:
    signal.c: avoid repeated disable/enable interrupt
    
    We only install system-level signal handlers during init (before any
    threads or user code is running), so there's no need to repeatedly
    enable/disable the interrupts at that time.  We also do not change
    system-level sig handlers once user-level code is running.
    
    This saves about 20 syscalls at startup and makes the executable
    smaller (numbers from 32-bit x86):
    
            text       data     bss     dec     hex filename
    before: 2815726   12100   30552 2858378  2b9d8a ruby
     after: 2815022   12100   30552 2857674  2b9aca ruby
    
    * signal.c (install_sighandler): remove rb_disable_interrupt and
      rb_enable_interrupt calls
      (init_sigchld): ditto
      (Init_signal): disable and enable interrupt once around all
      install_sighandler and init_sigchld to reduce syscalls at start
      [Feature #9345] [ruby-core:59480]

  Modified files:
    trunk/ChangeLog
    trunk/signal.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48177)
+++ ChangeLog	(revision 48178)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 28 16:52:07 2014  Eric Wong  <e@8...>
+
+	* signal.c (install_sighandler): remove rb_disable_interrupt and
+	  rb_enable_interrupt calls
+	  (init_sigchld): ditto
+	  (Init_signal): disable and enable interrupt once around all
+	  install_sighandler and init_sigchld to reduce syscalls at start
+	  [Feature #9345] [ruby-core:59480]
+
 Tue Oct 28 16:22:41 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* ruby.c (process_options, load_file_internal2): should not
Index: signal.c
===================================================================
--- signal.c	(revision 48177)
+++ signal.c	(revision 48178)
@@ -1298,15 +1298,12 @@ install_sighandler(int signum, sighandle https://github.com/ruby/ruby/blob/trunk/signal.c#L1298
 {
     sighandler_t old;
 
-    /* At this time, there is no subthread. Then sigmask guarantee atomics. */
-    rb_disable_interrupt();
     old = ruby_signal(signum, handler);
     if (old == SIG_ERR) return -1;
     /* signal handler should be inherited during exec. */
     if (old != SIG_DFL) {
 	ruby_signal(signum, old);
     }
-    rb_enable_interrupt();
     return 0;
 }
 #ifndef __native_client__
@@ -1319,7 +1316,6 @@ init_sigchld(int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1316
 {
     sighandler_t oldfunc;
 
-    rb_disable_interrupt();
     oldfunc = ruby_signal(sig, SIG_DFL);
     if (oldfunc == SIG_ERR) return -1;
     if (oldfunc != SIG_DFL && oldfunc != SIG_IGN) {
@@ -1328,7 +1324,6 @@ init_sigchld(int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L1324
     else {
 	GET_VM()->trap_list[sig].cmd = 0;
     }
-    rb_enable_interrupt();
     return 0;
 }
 #  ifndef __native_client__
@@ -1405,6 +1400,9 @@ Init_signal(void) https://github.com/ruby/ruby/blob/trunk/signal.c#L1400
     rb_alias(rb_eSignal, rb_intern_const("signm"), rb_intern_const("message"));
     rb_define_method(rb_eInterrupt, "initialize", interrupt_init, -1);
 
+    /* At this time, there is no subthread. Then sigmask guarantee atomics. */
+    rb_disable_interrupt();
+
     install_sighandler(SIGINT, sighandler);
 #ifdef SIGHUP
     install_sighandler(SIGHUP, sighandler);
@@ -1448,4 +1446,6 @@ Init_signal(void) https://github.com/ruby/ruby/blob/trunk/signal.c#L1446
 #elif defined(SIGCHLD)
     init_sigchld(SIGCHLD);
 #endif
+
+    rb_enable_interrupt();
 }

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

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