Bug #18560
closed"Compaction isn't available on this platform" error running PG test suite on ppc64le
Description
Trying to execute test suite of pg
gem on ppc64le, I observe a following error:
... snip ...
1) GC.compact should compact PG::TypeMapByClass #328
Failure/Error: GC.verify_compaction_references(toward: :empty, double_heap: true)
NotImplementedError:
Compaction isn't available on this platform
# <internal:gc>:257:in `verify_compaction_references'
# ./spec/pg/gc_compact_spec.rb:58:in `block (2 levels) i
... snip ...
This is surprising, given that the test suite seems to do reasonable effort to guard this behavior 1:
... snip ...
describe "GC.compact", if: GC.respond_to?(:compact) do
... snip ...
Is this expected or bug?
Updated by peterzhu2118 (Peter Zhu) almost 3 years ago
I think this is expected. GC.compact
, GC.auto_compact=
, GC.verify_compaction_references
will raise NotImplementedError
when compaction is not supported on the platform.
GC.respond_to?(:compact)
is just to check that the method GC.compact
exists (this method was added in Ruby 2.7).
Updated by mame (Yusuke Endoh) almost 3 years ago
@peterzhu2118 (Peter Zhu) JFYI: If the method body is rb_f_notimplement
, Kernel#respond_to?
returns false.
For example, Kernel#fork
is defined as such in Windows. https://github.com/ruby/ruby/blob/605f226142a47c4f9e4cc88717c5d6170bc3d7f1/process.c#L4431
PS C:\> ruby -ve 'p respond_to?(:fork); fork'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
false
-e:1:in `fork': fork() function is unimplemented on this machine (NotImplementedError)
from -e:1:in `<main>'
However, I think it is currently impossible to define such a method in Ruby code, i.e., gc.rb
. I have no opinion whether it is worth putting effort on this.
Updated by vo.x (Vit Ondruch) almost 3 years ago
Thx for the clarification. For now, I have reported the original issue to the PG upstream [1]. Keeping this open should there be a chance to follow the fork
example.
Updated by Eregon (Benoit Daloze) almost 3 years ago
FWIW, TruffleRuby has Primitive.method_unimplement
specifically to achieve to achieve the same as rb_f_notimplement
but in Ruby code.
Example usage: https://github.com/oracle/truffleruby/blob/4eddae9d18137567beb25e6e4ef2c932fa9de7ab/src/main/ruby/truffleruby/core/kernel.rb#L759
Updated by jaruga (Jun Aruga) over 2 years ago
I remember the Ruby disabled GC compaction on platforms that can't support it, on #17871 .
Updated by Eregon (Benoit Daloze) over 2 years ago
- Has duplicate Bug #18779: `GC.compact` and other compaction related methods should be defined as rb_f_notimplement on non supported platforms. added
Updated by Eregon (Benoit Daloze) over 2 years ago
- Status changed from Open to Closed
This seems the same as #18779, which just got fixed.