Skip to content

Instantly share code, notes, and snippets.

@khamusa
Last active April 25, 2018 18:39
Show Gist options
  • Save khamusa/57a7660a69c7021ea1c1dea92c73a0bc to your computer and use it in GitHub Desktop.
Save khamusa/57a7660a69c7021ea1c1dea92c73a0bc to your computer and use it in GitHub Desktop.
Patch for compiling ruby 2.4.0 supporting MEMORY and ALLOCATIONS metrics with rails-perftest gem
commit 043ab545e23347f0c55cad1d152dd8fb2c46fa21
Author: Samuel Brandão <gb.samuel@gmail.com>
Date: Wed Apr 25 15:16:19 2018 -0300
GC calculations of allocated size
diff --git a/gc.c b/gc.c
index 847062557f..4bd2284698 100644
--- a/gc.c
+++ b/gc.c
@@ -304,10 +304,10 @@ static ruby_gc_params_t gc_params = {
#endif
#if defined(HAVE_MALLOC_USABLE_SIZE) || CALC_EXACT_MALLOC_SIZE > 0
#ifndef MALLOC_ALLOCATED_SIZE
-#define MALLOC_ALLOCATED_SIZE 0
+#define MALLOC_ALLOCATED_SIZE 1
#endif
#else
-#define MALLOC_ALLOCATED_SIZE 0
+#define MALLOC_ALLOCATED_SIZE 1
#endif
#ifndef MALLOC_ALLOCATED_SIZE_CHECK
#define MALLOC_ALLOCATED_SIZE_CHECK 0
@khamusa
Copy link
Author

khamusa commented Apr 25, 2018

With rvm, the following should work, adding this patch and the railsexpress patches:

curl https://gist.githubusercontent.com/khamusa/57a7660a69c7021ea1c1dea92c73a0bc/raw/8d24362d4cc4ffe2720949f9557384ebb77a7a33/gc_malloc_allocations.patch > gc_malloc_allocations.patch
rvm install 2.4.0 --patch railsexpress --patch /home/samuel/projects/ruby/gc_malloc_allocations.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment