jemalloc_ctl 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/jemalloc_ctl/jemalloc_ctl.c +9 -12
- data/lib/jemalloc_ctl.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a11fb9644350e9484a4e0f6e0d7a4a89445ce6284e9ed5dc00bbb0314139ac7d
|
|
4
|
+
data.tar.gz: d4079ec48055491218452c0f054b742602f61fc55946c418621b7740ca06edcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44fcc93f7ac58f5b9e8da956d98e04a5608a4841555be26fa192bff9399e27600ee9048880d9ba15195a17c01f31bd3c501fe00de6e2a3d3b86636c7f791f7e1
|
|
7
|
+
data.tar.gz: b1162525fed73dd1a16c09d0b33d71c53d83c414e9c3731f1de6e83aa69ad0c9e1bf0a6d917d9db815c3342d4a7627b9c8f5504ba0e1cdf32f2e0c1006511947
|
|
@@ -54,12 +54,12 @@ static VALUE rb_jemalloc_ctl_version(VALUE self)
|
|
|
54
54
|
return rb_str_new_cstr(version);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
static VALUE
|
|
57
|
+
static VALUE rb_jemalloc_ctl_toggle_background_thread(VALUE self, VALUE onoff)
|
|
58
58
|
{
|
|
59
59
|
if (my_mallctl == NULL)
|
|
60
60
|
rb_raise(rb_eRuntimeError, "jemalloc is not available");
|
|
61
61
|
|
|
62
|
-
bool val =
|
|
62
|
+
bool val = RTEST(onoff);
|
|
63
63
|
int err = my_mallctl("background_thread", NULL, NULL, &val, sizeof(bool));
|
|
64
64
|
|
|
65
65
|
if (err != 0)
|
|
@@ -68,18 +68,18 @@ static VALUE rb_jemalloc_ctl_enable_background_thread(VALUE self)
|
|
|
68
68
|
return Qtrue;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
static VALUE
|
|
71
|
+
static VALUE rb_jemalloc_ctl_toggle_current_thread_tcache(VALUE self, VALUE onoff)
|
|
72
72
|
{
|
|
73
73
|
if (my_mallctl == NULL)
|
|
74
74
|
rb_raise(rb_eRuntimeError, "jemalloc is not available");
|
|
75
75
|
|
|
76
|
-
bool
|
|
77
|
-
int err = my_mallctl("
|
|
76
|
+
bool enabled = RTEST(onoff);
|
|
77
|
+
int err = my_mallctl("thread.tcache.enabled", NULL, NULL, &enabled, sizeof(enabled));
|
|
78
78
|
|
|
79
79
|
if (err != 0)
|
|
80
|
-
rb_raise(rb_eRuntimeError, "mallctl(\"
|
|
80
|
+
rb_raise(rb_eRuntimeError, "mallctl(\"thread.tcache.enabled\") failed with error %d", err);
|
|
81
81
|
|
|
82
|
-
return
|
|
82
|
+
return Qtrue;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
static VALUE rb_jemalloc_ctl_flush_current_thread_tcache(VALUE self)
|
|
@@ -118,9 +118,6 @@ static void write_stats_cb(void *opaque, const char *buf)
|
|
|
118
118
|
|
|
119
119
|
static VALUE rb_jemalloc_ctl_print_stats(VALUE self, VALUE filename)
|
|
120
120
|
{
|
|
121
|
-
if (my_mallctl == NULL)
|
|
122
|
-
rb_raise(rb_eRuntimeError, "jemalloc is not available");
|
|
123
|
-
|
|
124
121
|
if (my_malloc_stats_print == NULL)
|
|
125
122
|
rb_raise(rb_eRuntimeError, "malloc_stats_print is not available");
|
|
126
123
|
|
|
@@ -178,9 +175,9 @@ void Init_jemalloc_ctl(void)
|
|
|
178
175
|
rb_mJemallocCtl = rb_define_module("JemallocCtl");
|
|
179
176
|
rb_define_singleton_method(rb_mJemallocCtl, "enabled?", rb_jemalloc_ctl_enabled_p, 0);
|
|
180
177
|
rb_define_singleton_method(rb_mJemallocCtl, "version", rb_jemalloc_ctl_version, 0);
|
|
181
|
-
rb_define_singleton_method(rb_mJemallocCtl, "enable_background_thread", rb_jemalloc_ctl_enable_background_thread, 0);
|
|
182
|
-
rb_define_singleton_method(rb_mJemallocCtl, "disable_background_thread", rb_jemalloc_ctl_disable_background_thread, 0);
|
|
183
178
|
rb_define_singleton_method(rb_mJemallocCtl, "print_stats", rb_jemalloc_ctl_print_stats, 1);
|
|
179
|
+
rb_define_singleton_method(rb_mJemallocCtl, "toggle_background_thread", rb_jemalloc_ctl_toggle_background_thread, 1);
|
|
184
180
|
rb_define_singleton_method(rb_mJemallocCtl, "purge_arenas", rb_jemalloc_ctl_purge_arenas, 0);
|
|
185
181
|
rb_define_singleton_method(rb_mJemallocCtl, "flush_current_thread_tcache", rb_jemalloc_ctl_flush_current_thread_tcache, 0);
|
|
182
|
+
rb_define_singleton_method(rb_mJemallocCtl, "toggle_current_thread_tcache", rb_jemalloc_ctl_toggle_current_thread_tcache, 1);
|
|
186
183
|
}
|
data/lib/jemalloc_ctl.rb
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
require "jemalloc_ctl/jemalloc_ctl"
|
|
2
2
|
module JemallocCtl
|
|
3
|
+
def self.disable_background_thread
|
|
4
|
+
toggle_background_thread(false)
|
|
5
|
+
end
|
|
6
|
+
def self.enable_background_thread
|
|
7
|
+
toggle_background_thread(true)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.disable_current_thread_tcache
|
|
11
|
+
toggle_current_thread_tcache(false)
|
|
12
|
+
end
|
|
13
|
+
def self.enable_current_thread_tcache
|
|
14
|
+
toggle_current_thread_tcache(true)
|
|
15
|
+
end
|
|
3
16
|
end
|