[#47787] Ruby Parallelism — Miguel Palhas <mpalhas@...>
Greetings
[#47790] [ruby-trunk - Bug #7097][Open] Thread locals don't work inside Enumerator — "tenderlovemaking (Aaron Patterson)" <aaron@...>
On Tue, Oct 02, 2012 at 03:05:17AM +0900, kosaki (Motohiro KOSAKI) wrote:
(2012/10/02 3:12), Aaron Patterson wrote:
(2012/10/02 8:22), SASADA Koichi wrote:
On Tue, Oct 02, 2012 at 08:32:51AM +0900, SASADA Koichi wrote:
>> For example:
I don't have any objection.
On Fri, Oct 26, 2012 at 02:40:53PM +0900, SASADA Koichi wrote:
[#47832] [ruby-trunk - Feature #7106][Open] FileUtils.touch should allow touching the symlink itself rather than the file the link points to — "cirrusthinking (Alessandro Diaferia)" <alessandro@...>
[#47841] [ruby-trunk - Bug #7109][Open] File.utime doesn't set nanoseconds — "bkabrda (Bohuslav Kabrda)" <bkabrda@...>
2012/10/5 bkabrda (Bohuslav Kabrda) <[email protected]>:
[#47847] [ruby-trunk - Bug #7110][Open] CGI: Add support for HTML5 <header> tag — "stomar (Marcus Stollsteimer)" <redmine@...>
[#47880] [ruby-trunk - Bug #7134][Open] Signal handling bug in Mac OS X — "auastro (Andy Kitchen)" <kitchen.andy+rubybug@...>
[#47881] [ruby-trunk - Bug #7135][Open] GC bug in Ruby 1.9.3-p194? — "alexdowad (Alex Dowad)" <alexinbeijing@...>
[#47887] [ruby-trunk - Bug #7137][Open] Date.parse overly lenient when attempting to parse Monday? — "garysweaver (Gary Weaver)" <garysweaver@...>
[#47927] new ruby 1.9.3 maintainer — "U.Nakamura" <usa@...>
Hello everyone of the Ruby development community
[#47930] [ruby-trunk - Feature #7148][Open] Improved Tempfile w/o DelegateClass — "Glass_saga (Masaki Matsushita)" <glass.saga@...>
[#47963] [ruby-trunk - Bug #7154][Open] For whatever reason \s doesn't match \u00a0. — "t0d0r (Todor Dragnev)" <todor.dragnev@...>
[#47970] [ruby-trunk - Bug #7158][Open] require is slow in its bookkeeping; can make Rails startup 2.2x faster — "gregprice (Greg Price)" <price@...>
(2012/10/28 7:10), h.shirosaki (Hiroshi Shirosaki) wrote:
Thank you for the careful work.
[#48032] [Backport93 - Backport #7174][Open] Advocating for backporting 36811 — "jonforums (Jon Forums)" <redmine@...>
[#48040] Should Hash#dup automatically rehash — Aaron Patterson <tenderlove@...>
Hi,
[#48072] [ruby-trunk - Bug #7184][Open] --disable-gems commandline parameter does not show up with ruby -h — "steenslag (siep korteling)" <s.korteling@...>
[#48132] [ruby-trunk - Bug #7201][Open] Setting default_external affects STDIN encoding but default_internal does not — "brixen (Brian Ford)" <brixen@...>
[#48154] Patch to test_ssl to validate server-side support for SNI — Patrick Toomey <ptoomey3@...>
I recently made a pull request to JRuby (
We have incorporated Patrick's SNI patch for upcoming release JRuby
[#48191] [ANN] 2.0.0 feature freeze — Yusuke Endoh <mame@...>
Japanese later; 日本語は後で
Em 24-10-2012 09:39, Yusuke Endoh escreveu:
(2012/10/24 5:39), Yusuke Endoh wrote:
Hello ko1,
Hi,
AFAIK matz has not accepted #6636 completely yet.
Sorry, late to the party, but what's the status of #6679?
What status of #6638 <https://bugs.ruby-lang.org/issues/6638>
[#48260] [ruby-trunk - Bug #7214][Open] Ruby 2.0 breaks support for some debugging tools — "banister (john mair)" <jrmair@...>
[#48292] [ruby-trunk - Bug #7216][Open] object.c defines clone method for objects that cannot be cloned. — "therevmj (Michael Johnson)" <mj@...>
[#48315] [ruby-trunk - Bug #7220][Open] StringIO#initialize_copy causes aliasing between the objects — "brixen (Brian Ford)" <brixen@...>
[#48475] [ruby-trunk - Feature #3222] Can bignums have singleton class & methods? — "matz (Yukihiro Matsumoto)" <matz@...>
(2012/10/27 23:25), matz (Yukihiro Matsumoto) wrote:
[#48551] [ruby-trunk - Feature #7241][Open] Enumerable#to_h proposal — "nathan.f77 (Nathan Broadbent)" <nathan.f77@...>
On Tue, Oct 30, 2012 at 07:58:33PM +0900, rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
Em 30-10-2012 16:23, Aaron Patterson escreveu:
[#48679] [ruby-trunk - Feature #905] Add String.new(fixnum) to preallocate large buffer — "headius (Charles Nutter)" <headius@...>
[ruby-core:48377] [ruby-trunk - Feature #6602] Tail call optimization: enable by default?
Issue #6602 has been updated by ko1 (Koichi Sasada).
Target version changed from 2.0.0 to next minor
Alexey: to introduce new syntax (or method), we need more discussion (mainly on name ;)).
I changed target to next minor.
----------------------------------------
Feature #6602: Tail call optimization: enable by default?
https://bugs.ruby-lang.org/issues/6602#change-31689
Author: ko1 (Koichi Sasada)
Status: Assigned
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: core
Target version: next minor
=begin
Hi,
Some hours ago, Matz proposed turning on "tail call optimization" by default from Ruby 2.0.
What do you think about it?
= Background
Tail call: Method invocation at last of method body.
Tail call optimization: Eliminating the new stack frame creation when method invocation is "tail call".
For exmaple, the method bar() is located at last of method foo(), so bar() is "tail call".
def foo()
...
bar()
end
In this case, after invocation of method bar(), foo()'s method frame information (which contains local variables, program counter, stack pointer and so on) is no longer needed because method foo() doesn't work after that (correctly, method foo() only does "return").
Next example, a simple recursion code by foo(). Of course, foo() is "tail call".
def foo()
...
foo()
end
Current Ruby causes stack overflow error because such recursion consumes the (VM) stack. However, using tail call optimization, VM doesn't consume stack frame any more.
Such recursion can be converted to simple loop:
def foo
while true
foo()
end
end
Someone calls tail-call opt as "tail recursion optimization" because recursion is famous use-case (*1).
*1: Generally, tail-recursion optimization includes another optimization technique - "call" to "jump" translation. In my opinion, it is difficult to apply this optimization because recognizing "recursion" is difficult in Ruby's world.
Next example. fact() method invocation in "else" clause is *not* a "tail call".
def fact(n)
if n < 2
1
else
n * fact(n-1)
end
end
If you want to use tail-call optimization on fact() method, you need to change fact() method as follows (continuation passing style).
def fact(n, r)
if n < 2
r
else
fact(n-1, n*r)
end
end
In this case, fact() is tail-call (and a bit difficult to read/write).
Of course, the following code is easy to understand and short.
(1..n).inject(:*)
Last examples. Recognizing tail-call is a bit difficult.
def foo
begin
bar2() # not a tail-call
rescue
bar3() # not a tail-call
rescue
bar4() # not a tail-call
ensure
bar5() # tail-call!
end
end
def foo
while true
return bar("break") # tail-call? (current CRuby can't handle "break" in eval().
end
end
CRuby 1.9 has a code tail-call optimization (not tested yet. maybe there are several bugs). However, it is off by default because of several problems described in next section.
= Problems:
* (1) backtrace: Eliminating method frame means eliminating backtrace.
* (2) set_trace_func(): It is difficult to probe "return" event for tail-call methods.
* (3) semantics: It is difficult to define tail-call in document (half is joking, but half is serious)
References:
* [ruby-core:20273]
* [ruby-core:20307]
* [ruby-core:22736]
* [ruby-core:22790]
Maybe (1) has big impact for ordinal users.
For example:
def foo
bar()
end
def bar
baz()
end
def baz
raise("somethig error")
end
In this case, backtrace information only include "baz", because bar() in foo and baz() in bar are "tail-call". Users can't see eliminated frame information in backtrace.
This is why we don't introduce them by default to Ruby 1.9.
= Discussion
Many people ask us that "why don't you introduce tail-call optimization? it is very easy technique." I wrote reasons above.
Matz said "it seems small impact enough. Go ahead". (I doubt it ;P )
Yusuke Endo proposed that introducing special form (for example, send_tail(:foo, ...)) to declare tail call. Users only use this special form when the backtrace information can be eliminated (*2).
(*2) Special form "goto foo()" is nice joking feature :) I like it but I believe Matz will reject it.
Akira Tanaka introduced that special backtrace notation like:
baz
... (eliminated by tail call optimization)
main
to represent eliminating method invocation information. We can know they were eliminated (good) but we can't know what method frames were eliminated (bad).
= Conclusion
Matz wanted to introduce it. However it has several problems. Should we turn on this optimization by default?
Sorry for long (and poor English) article. Comments and proposals are welcome (with short English, long Ruby codes ;p).
Thanks,
Koichi
=end
--
http://bugs.ruby-lang.org/