"Compaction isn't available on this platform" error running PG test suite on ppc64le
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) 4 months ago
I think this is expected.
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) 4 months ago
@peterzhu2118 (Peter Zhu) JFYI: If the method body is
Kernel#respond_to? returns false.
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 Eregon (Benoit Daloze) 4 months 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