Eric Wong <normalperson / yhbt.net> wrote: > Kurt Stephens <ks.ruby / kurtstephens.com> wrote: > > Feature #5033: PATCH: 1.9: gc_mark_children: Avoid gc_mark() tail recursion, use goto again. > > http://redmine.ruby-lang.org/issues/5033 > > In [ruby-core:36931], ko1 told us GC eats stack when marking nested > objects. Kurt's patch should allow us to run smaller pthread stack > sizes while still supporting deeply-nested structures. shyouhei appears right about compilers being able to optimize this for the easy cases. However "inspect" on deeply-nested structures is still stack hungry and causes SystemStackErrors on my machine if I try to "p" a deeply-nested array or hash. > Kurt: can you test a smaller stack size with your patch with some > deeply-nested objects? I was playing around with something like this (but did not get any useful results/conclusion either way): def deeper!(array_or_hash, depth) if depth > 6000 $last = array_or_hash[0] = {} else array_or_hash[0] = [ deeper!({}, depth += 1) ] end end orig = {} deeper!(orig, 0) 5000.times do |i| deeper!($last, 0) end p $$ # give GC something to much on 100000.times { |i| i.to_s } p :done