[#21039] Happy new year and... moving Ruby development to Git? — Michael Klishin <michael.s.klishin@...>

Happy new year everyone.

94 messages 2009/01/01
[#21040] Re: Happy new year and... moving Ruby development to Git? — James Gray <james@...> 2009/01/01

On Jan 1, 2009, at 6:42 AM, Michael Klishin wrote:

[#21041] Re: Happy new year and... moving Ruby development to Git? — brabuhr@... 2009/01/01

On Thu, Jan 1, 2009 at 11:22 AM, James Gray <james@grayproductions.net> wrote:

[#21042] Re: Happy new year and... moving Ruby development to Git? — Federico Builes <federico.builes@...> 2009/01/01

brabuhr@gmail.com writes:

[#21049] Re: Happy new year and... moving Ruby development to Git? — Michael Klishin <michael.s.klishin@...> 2009/01/01

[#21053] Re: Happy new year and... moving Ruby development to Git? — znmeb@... 2009/01/01

Quoting Michael Klishin <michael.s.klishin@gmail.com>:

[#21068] Re: Happy new year and... moving Ruby development to Git? — Yukihiro Matsumoto <matz@...> 2009/01/02

Hi,

[#21069] Re: Happy new year and... moving Ruby development to Git? — Florian Gilcher <flo@...> 2009/01/02

-----BEGIN PGP SIGNED MESSAGE-----

[#21070] Re: Happy new year and... moving Ruby development to Git? — "Luis Lavena" <luislavena@...> 2009/01/02

T24gRnJpLCBKYW4gMiwgMjAwOSBhdCAxMjoxOCBQTSwgRmxvcmlhbiBHaWxjaGVyIDxmbG9AYW5k

[#21073] Re: Happy new year and... moving Ruby development to Git? — mathew <meta@...> 2009/01/02

My opinion:

[#21078] Re: Happy new year and... moving Ruby development to Git? — "Eust痃uio Rangel" <eustaquiorangel@...> 2009/01/02

My two cents:

[#21101] Re: Happy new year and... moving Ruby development to Git? — "M. Edward (Ed) Borasky" <znmeb@...> 2009/01/03

Eust=E1quio Rangel wrote:

[#21102] Re: Happy new year and... moving Ruby development to Git? — "Nikolai Weibull" <now@...> 2009/01/03

On Sat, Jan 3, 2009 at 21:40, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:

[#21104] Re: Happy new year and... moving Ruby development to Git? — "M. Edward (Ed) Borasky" <znmeb@...> 2009/01/03

Nikolai Weibull wrote:

[#21106] Re: Happy new year and... moving Ruby development to Git? — "Giuseppe Bilotta" <giuseppe.bilotta@...> 2009/01/04

On Sat, Jan 3, 2009 at 10:39 PM, M. Edward (Ed) Borasky

[#21114] Re: Happy new year and... moving Ruby development to Git? — Joel VanderWerf <vjoel@...> 2009/01/04

Giuseppe Bilotta wrote:

[#21132] Re: Happy new year and... moving Ruby development to Git? — Michael Klishin <michael.s.klishin@...> 2009/01/05

[#21134] Re: Happy new year and... moving Ruby development to Git? — Daniel Berger <djberg96@...> 2009/01/05

Michael Klishin wrote:

[#21080] Re: Happy new year and... moving Ruby development to Git? — Eric Hodel <drbrain@...7.net> 2009/01/02

On Jan 1, 2009, at 04:42 AM, Michael Klishin wrote:

[#21083] Re: Happy new year and... moving Ruby development to Git? — "Nikolai Weibull" <now@...> 2009/01/03

On Sat, Jan 3, 2009 at 00:34, Eric Hodel <drbrain@segment7.net> wrote:

[#21089] Re: Happy new year and... moving Ruby development to Git? — Michael Klishin <michael.s.klishin@...> 2009/01/03

[#21147] Re: Happy new year and... moving Ruby development to Git? — Paul Brannan <pbrannan@...> 2009/01/05

On Sat, Jan 03, 2009 at 12:48:09PM +0900, Michael Klishin wrote:

[#21160] Re: Happy new year and... moving Ruby development to Git? — Eric Hodel <drbrain@...7.net> 2009/01/05

On Jan 2, 2009, at 17:25 PM, Nikolai Weibull wrote:

[#21165] Re: Happy new year and... moving Ruby development to Git? — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2009/01/06

> I think I'm entitled to an opinion on the subject because I am a

[#21097] [Bug #977] caller for all threads patch — Roger Pack <redmine@...>

Bug #977: caller for all threads patch

15 messages 2009/01/03
[#23760] Re: [Bug #977] caller for all threads patch — SASADA Koichi <ko1@...> 2009/06/08

I made a patch to Thread#caller(lev=1). It may be more flexible than

[#21244] [Bug #999] SSL & ZIP missing from ruby-1.9.1-preview1-i386-mswin32 — William Mason <redmine@...>

Bug #999: SSL & ZIP missing from ruby-1.9.1-preview1-i386-mswin32

14 messages 2009/01/10

[#21259] Do I need a special build arg to get irb to accept utf characters on OSX — Dave Thomas <dave@...>

I'm seeing very strange behavior at the irb prompt with ruby 1.9.1 =20

10 messages 2009/01/11

[#21310] [Bug #1008] Missing shell version of ruby-1.9 commands (gem, rake, ...) for MinGW installation — Chauk-Mean Proum <redmine@...>

Bug #1008: Missing shell version of ruby-1.9 commands (gem, rake, ...) for MinGW installation

8 messages 2009/01/13

[#21339] [Bug #1010] Ruby-1.9's rake sh doesn't work on Windows (but fix provided) — Chauk-Mean Proum <redmine@...>

Bug #1010: Ruby-1.9's rake sh doesn't work on Windows (but fix provided)

10 messages 2009/01/14

[#21399] Proposal: Module#copy_method — Yehuda Katz <wycats@...>

I'd like it to be possible to copy methods from one module to another. The

38 messages 2009/01/18
[#21428] Re: Proposal: Module#copy_method — Yukihiro Matsumoto <matz@...> 2009/01/19

Hi,

[#21550] [Feature #1046] request: ability to run without specifying .rb — Roger Pack <redmine@...>

Feature #1046: request: ability to run without specifying .rb

13 messages 2009/01/24

[#21552] [Feature #1047] request: getters, setters for the GC — Roger Pack <redmine@...>

Feature #1047: request: getters, setters for the GC

15 messages 2009/01/24

[#21613] [Bug #1063] in `write': Not enough space - <STDOUT> (Errno::ENOMEM) on Windows XP — Nick Gorbikoff <redmine@...>

Bug #1063: in `write': Not enough space - <STDOUT> (Errno::ENOMEM) on Windows XP

11 messages 2009/01/27

[#21640] [Bug #1068] Ruby Cannot Handle Some UIDs — James Gray <redmine@...>

Bug #1068: Ruby Cannot Handle Some UIDs

12 messages 2009/01/28
[#21642] Re: [Bug #1068] Ruby Cannot Handle Some UIDs — Ondrej Bilka <neleai@...> 2009/01/28

On Wed, Jan 28, 2009 at 05:00:05PM +0100, James Gray wrote:

[#21663] Re: [Bug #1068] Ruby Cannot Handle Some UIDs — Nobuyoshi Nakada <nobu@...> 2009/01/29

Hi,

[#21701] [Feature #1081] add File::write() convenience method — Suraj Kurapati <redmine@...>

Feature #1081: add File::write() convenience method

34 messages 2009/01/31
[#28450] [Feature #1081] add File::write() convenience method — Yusuke Endoh <redmine@...> 2010/03/03

Issue #1081 has been updated by Yusuke Endoh.

[#28455] Re: [Feature #1081] add File::write() convenience method — Yukihiro Matsumoto <matz@...> 2010/03/04

Hi,

[#28472] Re: [Feature #1081] add File::write() convenience method — Yusuke ENDOH <mame@...> 2010/03/04

Hi,

[#21702] [Feature #1082] add Object#singleton_class method — Suraj Kurapati <redmine@...>

Feature #1082: add Object#singleton_class method

54 messages 2009/01/31
[#27372] [Feature #1082] add Object#singleton_class method — Suraj Kurapati <redmine@...> 2010/01/02

Issue #1082 has been updated by Suraj Kurapati.

[#27384] Re: [Feature #1082] add Object#singleton_class method — Yukihiro Matsumoto <matz@...> 2010/01/04

Hi,

[#27394] Re: [Feature #1082] add Object#singleton_class method — Yusuke ENDOH <mame@...> 2010/01/04

Hi,

[#27407] Re: [Feature #1082] add Object#singleton_class method — Shugo Maeda <shugo@...> 2010/01/05

Hi,

[#27409] Re: [Feature #1082] add Object#singleton_class method — Yukihiro Matsumoto <matz@...> 2010/01/05

Hi,

[#28304] Re: [Feature #1082] add Object#singleton_class method — Shugo Maeda <shugo@...> 2010/02/23

Hi,

[ruby-core:21302] [PATCH] drastically improve rb_waitpid for short-lived children

From: Evan Phoenix <evan@...>
Date: 2009-01-13 09:19:39 UTC
List: ruby-core #21302
This evening I wrote this patch while helping a friend diagnose why,  
when Threads are off, `system("date")` takes 2.2ms, and when Threads  
are on, 60ms.

The radical difference is a symptom of MRI's green threads and how you  
wait for a child in unix. The current implementation of system  
immediately calls rb_syswait(), which calls rb_waitpid() right after  
forking the child. rb_waitpid() calls waitpid(..., WNOHANG), which  
almost always returns nothing, since the child probably hasn't even  
actually started yet.

My patch improves upon this by adding a 5ms 'quicksleep' zone. At  
intervals of 0.5ms for the first 5ms after rb_waitpid is called,  
waitpid() is called in a loop. This allows short-lived, fast exiting  
children to be caught and processed almost right away, without  
incurring the 60ms minimum time we currently have.

The patch also adds a poll time backoff for use after the first 5ms.  
Rather than jumping right to backing off for 60ms, it backs off  
increments up to 60ms. This allows for children children that take  
just a little bit longer to be processed a bit quicker too.

For long running children, the behavior is the same.

This improves behavior a lot for users who run a lot of small, fast  
programs as children, in true unix style.

  - Evan Phoenix // evan@fallingsnow.net

Attachments (1)

ruby-187-fast-waitpid.diff (2.66 KB, text/x-diff)
diff -u -r ruby-1.8.7-p72/eval.c ruby-1.8.7-p72-mod/eval.c
--- ruby-1.8.7-p72/eval.c	2008-08-03 20:24:26.000000000 -0700
+++ ruby-1.8.7-p72-mod/eval.c	2009-01-13 00:48:28.000000000 -0800
@@ -11777,6 +11777,17 @@
 struct timeval rb_time_timeval();
 
 void
+rb_thread_polling_at(double time)
+{
+    if (curr_thread != curr_thread->next) {
+	curr_thread->status = THREAD_STOPPED;
+	curr_thread->delay = timeofday() + (double)time;
+	curr_thread->wait_for = WAIT_TIME;
+	rb_thread_schedule();
+    }
+}
+
+void
 rb_thread_polling()
 {
     if (curr_thread != curr_thread->next) {
diff -u -r ruby-1.8.7-p72/intern.h ruby-1.8.7-p72-mod/intern.h
--- ruby-1.8.7-p72/intern.h	2008-07-06 20:29:28.000000000 -0700
+++ ruby-1.8.7-p72-mod/intern.h	2009-01-13 00:49:01.000000000 -0800
@@ -215,6 +215,7 @@
 void rb_thread_fd_close _((int));
 int rb_thread_alone _((void));
 void rb_thread_polling _((void));
+void rb_thread_polling_at _((double));
 void rb_thread_sleep _((int));
 void rb_thread_sleep_forever _((void));
 VALUE rb_thread_stop _((void));
diff -u -r ruby-1.8.7-p72/process.c ruby-1.8.7-p72-mod/process.c
--- ruby-1.8.7-p72/process.c	2008-06-29 02:34:43.000000000 -0700
+++ ruby-1.8.7-p72-mod/process.c	2009-01-13 00:56:32.000000000 -0800
@@ -564,6 +564,11 @@
 static st_table *pid_tbl;
 #endif
 
+#define USE_WAIT_QUICKSLEEP
+#define WAIT_QUICKSLEEP_TIMES 10
+#define WAIT_POLL_TIME_MAX 0.06
+#define WAIT_POLL_BACKOFF_RATIO 1.3
+
 int
 rb_waitpid(pid, st, flags)
     int pid;
@@ -573,12 +578,15 @@
     int result;
 #ifndef NO_WAITPID
     int oflags = flags;
+    int times_through = 0;
+    double poll_time = 0.005;
     if (!rb_thread_alone()) {	/* there're other threads to run */
 	flags |= WNOHANG;
     }
 
   retry:
     TRAP_BEG;
+    times_through++;
 #ifdef HAVE_WAITPID
     result = waitpid(pid, st, flags);
 #else  /* HAVE_WAIT4 */
@@ -594,7 +602,23 @@
     }
     if (result == 0) {
 	if (oflags & WNOHANG) return 0;
-	rb_thread_polling();
+#ifdef USE_WAIT_QUICKSLEEP
+        // There are multiple threads enabled!
+        // Ok. There is a very good chance that the pid will return
+        // either really quickly or really slowly. So we'll do a quick
+        // nanosleep, then try again, then use rb_thread_polling
+        if(times_through < WAIT_QUICKSLEEP_TIMES) {
+          static struct timespec half_one_millisecond = { 0, 500000 };
+          nanosleep(&half_one_millisecond, NULL);
+          goto retry;
+        }
+#endif
+        // Back off the poll time until we exceed the max
+        if(poll_time < WAIT_POLL_TIME_MAX) {
+          poll_time *= WAIT_POLL_BACKOFF_RATIO;
+        }
+
+	rb_thread_polling_at(poll_time);
 	if (rb_thread_alone()) flags = oflags;
 	goto retry;
     }

In This Thread

Prev Next