From: jean.boussier@... Date: 2020-04-06T08:30:01+00:00 Subject: [ruby-core:97730] [Ruby master Feature#16761] Add an API to move the entire heap, as to make testing GC.compact compatibility easier Issue #16761 has been reported by byroot (Jean Boussier). ---------------------------------------- Feature #16761: Add an API to move the entire heap, as to make testing GC.compact compatibility easier https://bugs.ruby-lang.org/issues/16761 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal ---------------------------------------- We recently started testing GC.compact effectiveness in production, and one challenge we faced was to ensure that C extensions were compatible with it. Here's two examples of C-extensions which caused various issues, and their respective fixes: - https://github.com/Shopify/liquid-c/pull/55 - https://github.com/brianmario/mysql2/pull/1115 Every time the fix is quite straightforward, my problem is that it's almost impossible to write a reliable test case for it. With liquid-c I was able to reproduce the issue fairly constantly by calling `GC.compact` after loading the extension, but for some reason I was totally unable to do the same with `mysql2`. And even in production, the issue would only happen on a small number of processes. This makes me believe that having a debug method to move **all** objects on the heap would be very useful in this scenarios. There is already several `GC.verify_*` method intended to be used in debug scenarios, so there's precedent. I think something like `GC.move_all_the_heap` would make such testing much easier. e.g. ``` require 'c-ext' GC.move_all_the_heap # run the library tests ``` cc @tenderlovemaking -- https://bugs.ruby-lang.org/ Unsubscribe: