jemalloc_prof 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 398838afdd3797b0a8b405ae67a69cbf0923c677d4dd1ba79cf3461a5b9dd6cc
4
+ data.tar.gz: 4fba59910c6018ea53fb8d7297e905eecb94ee34d89833b6d341e67d6eb9e93b
5
+ SHA512:
6
+ metadata.gz: 4b1a7f90b945aff127db02ff57017fd91fb0d80a3e5986514b216301ac7f733018a3fb4ec1c692b1e52163e0c7e5c9f62f33367454a413fa41dbffe2685f129f
7
+ data.tar.gz: e6bfea82d8868e754691d1f2809635330a69b4a25f8a40dbbc486a5ff9bca5639e796e9feab26c595e7cfdcd1cd315200a32cec3a0af382d0ce1bd6588250840
@@ -0,0 +1,14 @@
1
+ require 'mkmf'
2
+
3
+ $LOCAL_LIBS << '-ljemalloc'
4
+
5
+ CC = "g++"
6
+ $LIBS << " -lstdc++"
7
+ case
8
+ when RUBY_PLATFORM.include?("darwin")
9
+ $CXXFLAGS += " -I /opt/homebrew/include"
10
+ $DLDFLAGS =+ " -L /opt/homebrew/lib"
11
+ when RUBY_PLATFORM.include?("linux")
12
+ # no op
13
+ end
14
+ create_makefile 'jemalloc_prof/jemalloc_prof_ext'
@@ -0,0 +1,34 @@
1
+ #include <stdlib.h>
2
+ #include <jemalloc/jemalloc.h>
3
+ #include <ruby.h>
4
+
5
+ typedef VALUE (ruby_method)(...);
6
+
7
+ static VALUE toggle(int enabled) {
8
+ VALUE result = Qnil;
9
+ bool en=(enabled == 1);
10
+ mallctl("prof.active", NULL, NULL, &en, sizeof(bool));
11
+ return result;
12
+ }
13
+
14
+ static VALUE enable(VALUE self) {
15
+ return toggle(1);
16
+ }
17
+
18
+ static VALUE disable(VALUE self) {
19
+ return toggle(0);
20
+ }
21
+
22
+ static VALUE dump(VALUE self) {
23
+ VALUE result = Qnil;
24
+ mallctl("prof.dump", NULL, NULL, NULL, 0);
25
+ return result;
26
+ }
27
+
28
+ static VALUE rbJemallocProf;
29
+ extern "C" void Init_jemalloc_prof_ext() {
30
+ rbJemallocProf = rb_define_module("JemallocProfExt");
31
+ rb_define_module_function (rbJemallocProf, "enable", (ruby_method*) &enable, 0);
32
+ rb_define_module_function (rbJemallocProf, "disable", (ruby_method*) &disable, 0);
33
+ rb_define_module_function (rbJemallocProf, "dump", (ruby_method*) &dump, 0);
34
+ }
@@ -0,0 +1,4 @@
1
+ class JemallocProf
2
+ require 'jemalloc_prof/jemalloc_prof_ext'
3
+ include ::JemallocProfExt
4
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jemalloc_prof
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michal Kulesza
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-02-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - mk@trou.pl
16
+ executables: []
17
+ extensions:
18
+ - ext/jemalloc_prof_ext/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ext/jemalloc_prof_ext/extconf.rb
22
+ - ext/jemalloc_prof_ext/jemalloc_prof_ext.cpp
23
+ - lib/jemalloc_prof.rb
24
+ homepage: https://github.com/mic-kul/jemalloc_prof
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.4.1
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Enable Jemalloc Profiler when needed
47
+ test_files: []