summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-11-24 21:29:45 -0800
committerAaron Patterson <tenderlove@ruby-lang.org>2020-11-24 21:30:13 -0800
commitfed67fe6b277361940e3357c8b1ffa455d7f2339 (patch)
tree4954b2cd3a2f3d65b6de29d3764e601b542c4c05 /test
parent00f046ef57f9da7f5248f9ef9d55702ddc407bf1 (diff)
Revert "Disable auto compaction on platforms that can't support it"
This reverts commit 63ad55cd882e4010fe313d271af006a430b5ffa8. Revert "Disable read barrier on explicit compaction request" This reverts commit 490b57783d80f0c5f7882c66d9fb6aa02713c9a5.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_gc_compact.rb112
1 files changed, 43 insertions, 69 deletions
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb
index 4a8cff33f4..3aad9e6d5f 100644
--- a/test/ruby/test_gc_compact.rb
+++ b/test/ruby/test_gc_compact.rb
@@ -1,82 +1,56 @@
# frozen_string_literal: true
require 'test/unit'
require 'fiddle'
-require 'etc'
class TestGCCompact < Test::Unit::TestCase
- class AutoCompact < Test::Unit::TestCase
- def setup
- skip "autocompact not supported on this platform" unless supports_auto_compact?
- super
- end
-
- def test_enable_autocompact
- before = GC.auto_compact
- GC.auto_compact = true
- assert GC.auto_compact
- ensure
- GC.auto_compact = before
- end
-
- def test_disable_autocompact
- before = GC.auto_compact
- GC.auto_compact = false
- refute GC.auto_compact
- ensure
- GC.auto_compact = before
- end
-
- def test_major_compacts
- before = GC.auto_compact
- GC.auto_compact = true
- compact = GC.stat :compact_count
- GC.start
- assert_operator GC.stat(:compact_count), :>, compact
- ensure
- GC.auto_compact = before
- end
-
- def test_implicit_compaction_does_something
- before = GC.auto_compact
- list = []
- list2 = []
-
- # Try to make some fragmentation
- 500.times {
- list << Object.new
- Object.new
- Object.new
- }
- count = GC.stat :compact_count
- GC.auto_compact = true
- loop do
- break if count < GC.stat(:compact_count)
- list2 << Object.new
- end
- compact_stats = GC.latest_compact_info
- refute_predicate compact_stats[:considered], :empty?
- refute_predicate compact_stats[:moved], :empty?
- ensure
- GC.auto_compact = before
- end
+ def test_enable_autocompact
+ before = GC.auto_compact
+ GC.auto_compact = true
+ assert GC.auto_compact
+ ensure
+ GC.auto_compact = before
+ end
- private
+ def test_disable_autocompact
+ before = GC.auto_compact
+ GC.auto_compact = false
+ refute GC.auto_compact
+ ensure
+ GC.auto_compact = before
+ end
- def supports_auto_compact?
- return true unless defined?(Etc::SC_PAGE_SIZE)
+ def test_major_compacts
+ before = GC.auto_compact
+ GC.auto_compact = true
+ compact = GC.stat :compact_count
+ GC.start
+ assert_operator GC.stat(:compact_count), :>, compact
+ ensure
+ GC.auto_compact = before
+ end
- begin
- return GC::INTERNAL_CONSTANTS[:HEAP_PAGE_SIZE] % Etc.sysconf(Etc::SC_PAGE_SIZE) == 0
- rescue NotImplementedError
- rescue ArgumentError
- end
+ def test_implicit_compaction_does_something
+ before = GC.auto_compact
+ list = []
+ list2 = []
- true
+ # Try to make some fragmentation
+ 500.times {
+ list << Object.new
+ Object.new
+ Object.new
+ }
+ count = GC.stat :compact_count
+ GC.auto_compact = true
+ loop do
+ break if count < GC.stat(:compact_count)
+ list2 << Object.new
end
- end
-
- def os_page_size
- return true unless defined?(Etc::SC_PAGE_SIZE)
+ compact_stats = GC.latest_compact_info
+ refute_predicate compact_stats[:considered], :empty?
+ refute_predicate compact_stats[:moved], :empty?
+ ensure
+ GC.auto_compact = before
end
def test_gc_compact_stats