Project

General

Profile

Actions

Feature #16761

open

Add an API to move the entire heap, as to make testing GC.compact compatibility easier

Added by byroot (Jean Boussier) over 4 years ago. Updated over 4 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:97730]

Description

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:

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 (Aaron Patterson)

Actions

Also available in: Atom PDF

Like0
Like0