gctools 0.2.3 → 0.2.4

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjljNDc0ZTJlODRiODIyNzE0MTFlYTJlYTE4ZWUxYzc2MzU4MjgzYQ==
5
- data.tar.gz: !binary |-
6
- MWJhNWZmZjZjY2RkNTlhYWY0M2JmZTdjYjk1ODE3OWU5NDVkNzk5Ng==
2
+ SHA1:
3
+ metadata.gz: cdf4e1fc73eda1b540f37f0acb8ef1e3aa8c11a8
4
+ data.tar.gz: 4f7e7d7602e755fef8bbc6aee049609c839138fd
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MjBkNTBkNzA2NDNlYTU2MzhiMjc5NzMyODI1NTEzZmI2ZTRjZGZhNWQwNjI5
10
- YmExYWU5ODJjMjI3MjE4ZGE3MWFkNTBmZmU0NGEwMmZmMzA0NjU0NDhmMDg2
11
- NDk5YzQ0MmRlZDNiMTZkMWFjZWVlNTNhM2RiMTU4YzM4MjA2NTA=
12
- data.tar.gz: !binary |-
13
- ODFmZGM1OWE0MWFmNTUwNWZmYjE4N2MyMDdmYzAwZTk5Nzg4NDZiZWU5OTc2
14
- MGMyNDgxNmZkOGUwMjlkMTdlNmQxMWY3NzA4OWUxYjMwMTVhY2MyZjljNTgw
15
- NjBjNjVkM2FhZDFjM2FmNmRiOTIxYmU5MmI0YTVmMjcxZWYyNTU=
6
+ metadata.gz: b2bea28697a4bbcb2ce14366017baf18f893e7bd4e187b03f3b0b94ad11a5de35e0b20f68508ad6600414bc61111d9c41d2c8f7be69637e4ce92fa749484dc7c
7
+ data.tar.gz: 2bb6d8c558d9952d813ef6535827463f1ab087811123aca71dbed76a39108795da7848a52522b43fed34630b052f0d0d12f746c3daa82a917b44e07ba143a56b
@@ -6,6 +6,7 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ minitest (5.8.3)
9
10
  rake (10.1.0)
10
11
  rake-compiler (0.9.2)
11
12
  rake
@@ -15,4 +16,5 @@ PLATFORMS
15
16
 
16
17
  DEPENDENCIES
17
18
  gctools!
19
+ minitest (~> 5.0)
18
20
  rake-compiler (~> 0.9)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2014 Aman Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -26,5 +26,4 @@ require 'gctools/logger'
26
26
  require 'gctools/oobgc'
27
27
  GC::OOB.run # after every request
28
28
  use(GC::OOB::UnicornMiddleware) # in config.ru for unicorn
29
- use(GC::OOB::PumaMiddleware) # in config.ru for puma
30
29
  ```
@@ -1,6 +1,7 @@
1
1
  #include <time.h>
2
2
  #include <sys/time.h>
3
3
  #include "ruby/ruby.h"
4
+ #include "ruby/version.h"
4
5
  #include "ruby/intern.h"
5
6
  #include "ruby/debug.h"
6
7
 
@@ -14,8 +15,8 @@ struct {
14
15
  size_t heap_obj_limit;
15
16
 
16
17
  struct {
17
- size_t total_allocated_object;
18
- size_t heap_tomb_page_length;
18
+ size_t total_allocated_objects;
19
+ size_t heap_tomb_pages;
19
20
  } start;
20
21
 
21
22
  struct {
@@ -31,8 +32,8 @@ struct {
31
32
  } _oobgc;
32
33
 
33
34
  static VALUE mOOB;
34
- static VALUE sym_total_allocated_object, sym_heap_swept_slot, sym_heap_tomb_page_length, sym_heap_final_slot;
35
- static VALUE sym_old_object, sym_old_object_limit, sym_remembered_shady_object, sym_remembered_shady_object_limit;
35
+ static VALUE sym_total_allocated_objects, sym_heap_swept_slots, sym_heap_tomb_pages, sym_heap_final_slots;
36
+ static VALUE sym_old_objects, sym_old_objects_limit, sym_remembered_wb_unprotected_objects, sym_remembered_wb_unprotected_objects_limit;
36
37
  static VALUE sym_major_by, sym_count, sym_major_count, sym_minor_count, sym_sweep_count, minor_gc_args;
37
38
  static ID id_start;
38
39
 
@@ -45,8 +46,8 @@ gc_event_i(VALUE tpval, void *data)
45
46
  switch (flag) {
46
47
  case RUBY_INTERNAL_EVENT_GC_START:
47
48
  _oobgc.allocation_limit = 0;
48
- _oobgc.start.total_allocated_object = rb_gc_stat(sym_total_allocated_object);
49
- _oobgc.start.heap_tomb_page_length = rb_gc_stat(sym_heap_tomb_page_length);
49
+ _oobgc.start.total_allocated_objects = rb_gc_stat(sym_total_allocated_objects);
50
+ _oobgc.start.heap_tomb_pages = rb_gc_stat(sym_heap_tomb_pages);
50
51
  break;
51
52
 
52
53
  case RUBY_INTERNAL_EVENT_GC_END_MARK:
@@ -56,10 +57,10 @@ gc_event_i(VALUE tpval, void *data)
56
57
  case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
57
58
  _oobgc.sweep_needed = 0;
58
59
  _oobgc.allocation_limit =
59
- _oobgc.start.total_allocated_object +
60
- rb_gc_stat(sym_heap_swept_slot) +
61
- (rb_gc_stat(sym_heap_tomb_page_length) * _oobgc.heap_obj_limit) -
62
- rb_gc_stat(sym_heap_final_slot);
60
+ _oobgc.start.total_allocated_objects +
61
+ rb_gc_stat(sym_heap_swept_slots) +
62
+ (rb_gc_stat(sym_heap_tomb_pages) * _oobgc.heap_obj_limit) -
63
+ rb_gc_stat(sym_heap_final_slots);
63
64
  break;
64
65
  }
65
66
  }
@@ -106,7 +107,7 @@ gc_start_minor()
106
107
  static VALUE
107
108
  oobgc(VALUE self)
108
109
  {
109
- size_t curr = rb_gc_stat(sym_total_allocated_object);
110
+ size_t curr = rb_gc_stat(sym_total_allocated_objects);
110
111
  if (!_oobgc.installed) install();
111
112
 
112
113
  if (!_oobgc.prev_allocated_object) {
@@ -135,11 +136,11 @@ oobgc(VALUE self)
135
136
  return Qtrue;
136
137
 
137
138
  } else if (_oobgc.allocation_limit) {
138
- /* GC will be required when total_allocated_object gets
139
+ /* GC will be required when total_allocated_objects gets
139
140
  * close to allocation_limit
140
141
  */
141
- if ((rb_gc_stat(sym_old_object) >= rb_gc_stat(sym_old_object_limit)*0.97 ||
142
- rb_gc_stat(sym_remembered_shady_object) >= rb_gc_stat(sym_remembered_shady_object_limit)*0.97) &&
142
+ if ((rb_gc_stat(sym_old_objects) >= rb_gc_stat(sym_old_objects_limit)*0.97 ||
143
+ rb_gc_stat(sym_remembered_wb_unprotected_objects) >= rb_gc_stat(sym_remembered_wb_unprotected_objects_limit)*0.97) &&
143
144
  curr >= _oobgc.allocation_limit - _oobgc.threshold.max*0.98) {
144
145
  /*fprintf(stderr, "oobgc MAJOR: %zu >= %zu - %zu\n", curr, _oobgc.allocation_limit, _oobgc.threshold.max);*/
145
146
  gc_start_major();
@@ -185,24 +186,29 @@ Init_oobgc()
185
186
  {
186
187
  mOOB = rb_define_module_under(rb_mGC, "OOB");
187
188
  rb_autoload(mOOB, rb_intern_const("UnicornMiddleware"), "gctools/oobgc/unicorn_middleware.rb");
188
- rb_autoload(mOOB, rb_intern_const("PumaMiddleware"), "gctools/oobgc/puma_middleware.rb");
189
189
 
190
190
  rb_define_singleton_method(mOOB, "setup", install, 0);
191
191
  rb_define_singleton_method(mOOB, "run", oobgc, 0);
192
192
  rb_define_singleton_method(mOOB, "stat", oobgc_stat, 1);
193
193
  rb_define_singleton_method(mOOB, "clear", oobgc_clear, 0);
194
194
 
195
- #define S(name) sym_##name = ID2SYM(rb_intern(#name));
196
- S(total_allocated_object);
197
- S(heap_swept_slot);
198
- S(heap_tomb_page_length);
199
- S(heap_final_slot);
200
-
201
- S(old_object);
202
- S(old_object_limit);
203
- S(remembered_shady_object);
204
- S(remembered_shady_object_limit);
195
+ #if (RUBY_API_VERSION_MAJOR == 2) && (RUBY_API_VERSION_MINOR == 1)
196
+ #define S(name, legacy_name) sym_##name = ID2SYM(rb_intern(#legacy_name))
197
+ #else
198
+ #define S(name, legacy_name) sym_##name = ID2SYM(rb_intern(#name))
199
+ #endif
200
+ S(total_allocated_objects, total_allocated_object);
201
+ S(heap_swept_slots, heap_swept_slot);
202
+ S(heap_tomb_pages, heap_tomb_page_length);
203
+ S(heap_final_slots, heap_final_slot);
204
+
205
+ S(old_objects, old_object);
206
+ S(old_objects_limit, old_object_limit);
207
+ S(remembered_wb_unprotected_objects, remembered_shady_object);
208
+ S(remembered_wb_unprotected_objects_limit, remembered_shady_object_limit);
209
+ #undef S
205
210
 
211
+ #define S(name) sym_##name = ID2SYM(rb_intern(#name))
206
212
  S(major_by);
207
213
  S(count);
208
214
  S(major_count);
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gctools'
3
- s.version = '0.2.3'
3
+ s.version = '0.2.4'
4
4
  s.summary = 'rgengc tools for ruby 2.1+'
5
5
  s.description = 'gc debugger, logger and profiler for rgengc in ruby 2.1'
6
6
 
@@ -12,4 +12,5 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
  s.extensions = ['ext/gcprof/extconf.rb', 'ext/oobgc/extconf.rb']
14
14
  s.add_development_dependency 'rake-compiler', '~> 0.9'
15
+ s.add_development_dependency 'minitest', '~> 5.0'
15
16
  end
@@ -1,7 +1,7 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'gctools/gcprof'
3
3
 
4
- class TestGCProf < Test::Unit::TestCase
4
+ class TestGCProf < Minitest::Test
5
5
  def teardown
6
6
  GCProf.after_gc_hook = nil
7
7
  end
@@ -1,8 +1,10 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'gctools/oobgc'
3
3
  require 'json'
4
4
 
5
- class TestOOBGC < Test::Unit::TestCase
5
+ class TestOOBGC < Minitest::Test
6
+ HEAP_SWEPT_SLOTS_KEY = RUBY_VERSION >= "2.2" ? :heap_swept_slots : :heap_swept_slot
7
+
6
8
  def setup
7
9
  GC::OOB.setup
8
10
  GC::OOB.clear
@@ -12,9 +14,9 @@ class TestOOBGC < Test::Unit::TestCase
12
14
  GC.start(immediate_sweep: false)
13
15
  assert_equal false, GC.latest_gc_info(:immediate_sweep)
14
16
 
15
- before = GC.stat(:heap_swept_slot)
17
+ before = GC.stat(HEAP_SWEPT_SLOTS_KEY)
16
18
  assert_equal true, GC::OOB.run
17
- assert_operator GC.stat(:heap_swept_slot), :>, before
19
+ assert_operator GC.stat(HEAP_SWEPT_SLOTS_KEY), :>, before
18
20
  end
19
21
 
20
22
  def test_oob_mark
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gctools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
27
41
  description: gc debugger, logger and profiler for rgengc in ruby 2.1
28
42
  email: aman@tmm1.net
29
43
  executables: []
@@ -32,9 +46,10 @@ extensions:
32
46
  - ext/oobgc/extconf.rb
33
47
  extra_rdoc_files: []
34
48
  files:
35
- - .gitignore
49
+ - ".gitignore"
36
50
  - Gemfile
37
51
  - Gemfile.lock
52
+ - LICENSE
38
53
  - README.md
39
54
  - Rakefile
40
55
  - ext/gcprof/extconf.rb
@@ -43,7 +58,6 @@ files:
43
58
  - ext/oobgc/oobgc.c
44
59
  - gctools.gemspec
45
60
  - lib/gctools/logger.rb
46
- - lib/gctools/oobgc/puma_middleware.rb
47
61
  - lib/gctools/oobgc/unicorn_middleware.rb
48
62
  - test/test_gcprof.rb
49
63
  - test/test_oobgc.rb
@@ -57,19 +71,18 @@ require_paths:
57
71
  - lib
58
72
  required_ruby_version: !ruby/object:Gem::Requirement
59
73
  requirements:
60
- - - ! '>='
74
+ - - ">="
61
75
  - !ruby/object:Gem::Version
62
76
  version: '0'
63
77
  required_rubygems_version: !ruby/object:Gem::Requirement
64
78
  requirements:
65
- - - ! '>='
79
+ - - ">="
66
80
  - !ruby/object:Gem::Version
67
81
  version: '0'
68
82
  requirements: []
69
83
  rubyforge_project:
70
- rubygems_version: 2.1.11
84
+ rubygems_version: 2.2.3
71
85
  signing_key:
72
86
  specification_version: 4
73
87
  summary: rgengc tools for ruby 2.1+
74
88
  test_files: []
75
- has_rdoc:
@@ -1,16 +0,0 @@
1
- require 'gctools/oobgc'
2
-
3
- module GC
4
- module OOB
5
- class PumaMiddleware
6
- def initialize(app, name = nil)
7
- @app = app
8
- end
9
- def call(env)
10
- status, header, body = @app.call(env)
11
- env['rack.after_reply'] << lambda { GC::OOB.run }
12
- [status, header, body]
13
- end
14
- end
15
- end
16
- end