From: "jeremyevans0 (Jeremy Evans) via ruby-core" Date: 2023-04-15T22:14:09+00:00 Subject: [ruby-core:113264] [Ruby master Bug#4040] SystemStackError with Hash[*a] for Large _a_ Issue #4040 has been updated by jeremyevans0 (Jeremy Evans). I ran yjit-bench with both the master branch and the PR branch. Here are the results: ``` Total time spent benchmarking: 5172s master: ruby 3.3.0dev (2023-04-14T03:43:46Z master 3733ee835b) [x86_64-openbsd7.3] heap_argv: ruby 3.3.0dev (2023-04-15T06:35:36Z large-array-splat-.. a0eb73211c) [x86_64-openbsd7.3] -------------- ----------- ---------- -------------- ---------- ---------------- ----------------- bench master (ms) stddev (%) heap_argv (ms) stddev (%) master/heap_argv heap_argv 1st itr activerecord 150.8 2.4 150.9 2.1 1.00 0.97 erubi_rails 52.6 7.9 52.9 8.1 1.00 1.05 hexapdf 6996.9 1.0 6925.5 0.6 1.01 1.11 liquid-c 177.5 2.0 175.3 1.5 1.01 1.03 liquid-compile 165.6 2.8 165.5 2.0 1.00 1.01 liquid-render 372.2 0.6 374.9 1.6 0.99 1.01 mail 389.6 0.7 394.0 2.0 0.99 1.01 psych-load 6431.2 0.2 6356.4 0.3 1.01 1.01 railsbench 4654.3 0.3 4696.0 0.6 0.99 0.99 ruby-lsp 159.6 6.0 155.6 5.8 1.03 1.05 sequel 215.0 2.6 214.8 0.9 1.00 1.00 binarytrees 840.2 0.3 840.2 0.9 1.00 0.99 chunky_png 2710.0 0.2 2739.4 0.4 0.99 0.98 erubi 732.7 1.6 726.9 1.1 1.01 1.02 etanni 984.5 1.6 974.1 0.5 1.01 1.01 fannkuchredux 4282.9 0.2 4334.9 0.2 0.99 0.99 lee 3625.8 0.4 3594.9 0.3 1.01 1.01 nbody 183.7 0.9 178.7 0.2 1.03 1.03 optcarrot 9673.8 1.0 9626.9 0.9 1.00 1.01 ruby-json 9889.0 0.1 9848.9 0.4 1.00 1.01 rubykon 23063.9 0.5 22953.8 0.3 1.00 1.00 30k_ifelse 3829.2 0.5 3824.4 1.0 1.00 0.99 30k_methods 7761.7 0.2 7665.6 0.2 1.01 1.01 cfunc_itself 327.7 0.3 326.6 0.5 1.00 1.00 fib 466.2 0.3 469.2 0.6 0.99 1.00 getivar 221.7 0.6 222.1 0.3 1.00 1.00 keyword_args 652.6 0.2 653.2 0.3 1.00 1.00 respond_to 893.4 0.2 909.5 0.1 0.98 0.98 setivar 148.3 0.3 143.5 0.2 1.03 1.01 setivar_object 295.0 0.5 291.6 0.5 1.01 1.01 setivar_young 295.1 0.4 291.6 0.6 1.01 1.01 str_concat 231.9 3.2 211.0 2.3 1.10 1.07 throw 40.2 1.3 41.6 9.2 0.97 0.98 -------------- ----------- ---------- -------------- ---------- ---------------- ----------------- Legend: - master/heap_argv: ratio of master/heap_argv time. Higher is better for heap_argv. Above 1 represents a speedup. - heap_argv 1st itr: ratio of master/heap_argv time for the first benchmarking iteration. ``` So it looks like it is slower on 8 benchmarks (6 1% slower, 1 2% slower, 1 3% slower), and faster on 13 benchmarks (9 1% faster, 3 3% faster, 1 10% faster). So on the whole, it looks like a net performance increase. It would be good to get benchmark results from Linux, so if someone could contribute that, I would appreciate it. ---------------------------------------- Bug #4040: SystemStackError with Hash[*a] for Large _a_ https://bugs.ruby-lang.org/issues/4040#change-102825 * Author: runpaint (Run Paint Run Run) * Status: Open * Priority: Normal * Assignee: ko1 (Koichi Sasada) * ruby -v: ruby 1.9.3dev (2010-11-09 trunk 29737) [x86_64-linux] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- =begin I've been hesitating over whether to file a ticket about this, so please feel free to close if I've made the wrong choice. I often use Hash[*array.flatten] in IRB to convert arrays of arrays into hashes. Today I noticed that if the array is big enough, this would raise a SystemStackError. Puzzled, I looked deeper. I assumed I was hitting the maximum number of arguments a method's argc can hold, but realised that the minimum size of the array needed to trigger this exception differed depending on whether I used IRB or not. So, presumably this is indeed exhausting the stack... In IRB, the following is the minimal reproduction of this problem: Hash[*130648.times.map{ 1 }]; true I haven't looked for the minimum value needed with `ruby -e`, but the following reproduces: ruby -e 'Hash[*1380888.times.map{ 1 }]' I suppose this isn't technically a bug, but maybe it offers another argument for either #666 or an extension of #3131. =end -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/