Feature #4568

[PATCH] file.c (rb_group_member): kill 256K of stack usage

Added by Eric Wong about 3 years ago. Updated almost 3 years ago.

[ruby-core:<unknown>]
Status:Closed
Priority:Low
Assignee:Motohiro KOSAKI
Category:core
Target version:2.0.0

Description

=begin
It was using 256K stack on my x86_64 machine.

Found with scripts/checkstack.pl in the Linux kernel source:

objdump -D ./ruby | ~/linux-2.6/scripts/checkstack.pl x86_64

Also pushed to my repo: git pull git://bogomips.org/ruby stack-reduce

=end

0001-file.c-rb_group_member-kill-256K-of-stack-usage.patch Magnifier (1.21 KB) Eric Wong, 04/11/2011 04:01 PM

History

#1 Updated by Eric Wong about 3 years ago

=begin
Lowering RUBYSTACKMINLIMIT to 64KB across the board in
thread
pthread.c seems to work fine for check, test-rubyspec,
benchmark-each.

No real code, though, and I also don't know what outside C extensions
do, but 64KB is the PTHREADSTACKMIN for my platform (and I've always
felt it was too high).

diff --git a/threadpthread.c b/threadpthread.c
index ad6f716..a015873 100644
--- a/threadpthread.c
+++ b/thread
pthread.c
@@ -630,11 +630,7 @@ usecachedthread(rbthreadt *th)
}

enum {
-#ifdef SYMBIAN32
- RUBYSTACKMINLIMIT = 64 * 1024, /* 64KB: Let's be slightly more frugal on mobile platform */
-#else
- RUBY
STACKMINLIMIT = 512 * 1024, /* 512KB /
-#endif
+ RUBYSTACKMIN_LIMIT = 64 * 1024, /
64KB */
RUBYSTACKSPACE_LIMIT = 1024 * 1024
};

--
Eric Wong
=end

#2 Updated by Motohiro KOSAKI about 3 years ago

  • Status changed from Open to Closed
  • Assignee set to Motohiro KOSAKI

=begin
Commited by r31259.
=end

#3 Updated by Eric Wong about 3 years ago

=begin
Lowering RUBYSTACKMINLIMIT to 64KB across the board in
thread
pthread.c seems to work fine for check, test-rubyspec,
benchmark-each.

No real code, though, and I also don't know what outside C extensions
do, but 64KB is the PTHREADSTACKMIN for my platform (and I've always
felt it was too high).

diff --git a/threadpthread.c b/threadpthread.c
index ad6f716..a015873 100644
--- a/threadpthread.c
+++ b/thread
pthread.c
@@ -630,11 +630,7 @@ usecachedthread(rbthreadt *th)
}

enum {
-#ifdef SYMBIAN32
- RUBYSTACKMINLIMIT = 64 * 1024, /* 64KB: Let's be slightly more frugal on mobile platform */
-#else
- RUBY
STACKMINLIMIT = 512 * 1024, /* 512KB /
-#endif
+ RUBYSTACKMIN_LIMIT = 64 * 1024, /
64KB */
RUBYSTACKSPACE_LIMIT = 1024 * 1024
};

--
Eric Wong
=end

#4 Updated by Eric Wong about 3 years ago

=begin
Eric Wong normalperson@yhbt.net wrote:

Lowering RUBYSTACKMINLIMIT to 64KB across the board in
thread
pthread.c seems to work fine for check, test-rubyspec,
benchmark-each.

No real code, though, and I also don't know what outside C extensions
do, but 64KB is the PTHREADSTACKMIN for my platform (and I've always
felt it was too high).

I was wrong about 64KB on my system 16KB is the minimum with NPTL :x

The lowest successful stack size I've been able to run is 48K, I get
stack corruption and GC failures with 44K and lower.

I've also run my Rainbows! web server[1] integration/torture test suite
with several threaded options and everything pased with 48K and didn't
notice ill effects. 44K seemed fine, too, I think, but 32K failed
Rainbows! tests miserably.

To be on the safe side with existing code/extensions and maybe some
overaggressive alloca() calls, I think 64KB is reasonable.

[1] - http://rainbows.rubyforge.org/ + http://bogomips.org/rainbows.git

--
Eric Wong
=end

Also available in: Atom PDF