aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-21 12:38:25 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-07-26 11:41:23 +0200
commit9b405a18bea7825cba794e42a1fef58a48451ec3 (patch)
treeebe4d86d88df1a9dad5ea0e19e39d1b47ce6ca2f /test/ruby
parent283b2fdab4be77d8721d7cf298168eb6e3798490 (diff)
downloadruby-9b405a18bea7825cba794e42a1fef58a48451ec3.tar.gz
Process.warmup: precompute strings coderange
This both save time for when it will be eventually needed, and avoid mutating heap pages after a potential fork. Instrumenting some large Rails app, I've witnessed up to 58% of String instances having their coderange still unknown.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_process.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 6ca16733bb..9846f5e2db 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -2709,4 +2709,16 @@ EOS
assert_equal compact_count + 1, GC.stat(:compact_count)
end;
end
+
+ def test_warmup_precompute_string_coderange
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+ require 'objspace'
+ begin;
+ obj = "a" * 12
+ obj.force_encoding(Encoding::BINARY)
+ assert_include(ObjectSpace.dump(obj), '"coderange":"unknown"')
+ Process.warmup
+ assert_include(ObjectSpace.dump(obj), '"coderange":"7bit"')
+ end;
+ end
end