gc_tracer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f02605c54bfd6ac29179037b21d3af38c7c8e0bd
4
- data.tar.gz: a7a328f0b154d4952bf7ca57f669303d53b341a3
3
+ metadata.gz: 8dc2c6bb5c46aff59932491cfdff071e7bd7f906
4
+ data.tar.gz: 44ed09676b1e928032b034060f00e17efa5c96c0
5
5
  SHA512:
6
- metadata.gz: 7e8bef62c7648c00b1a25dcfd0370ad53f8ee1b6dd9f210535f723982a60fcb05e8a75cfaaedd74f40c6d8d449248f1abce5a0ab2cb4e1ee07b1dfffa1264f9c
7
- data.tar.gz: 76228e7ed79f5e94f45a732e0b7ca8fb26f69bcf36bac5dd058a78561cdcf883e4f9474c749b9efe31582e09a10fbbd108b99513a984cf373bd205ac4d6b2557
6
+ metadata.gz: e1ed113ec6986087c61ab8460925bab0bb20a14731e2954ec94d43c1f84eb56b2476f72a2ab0a7ceb073471093887b0cabb3223655f8ecc88b7c134adfcd689c
7
+ data.tar.gz: 2c1cc72df37053edb0b610678f0587ccd5142121ae2232742ab978c843040f513573ed6c122b28ef61c6e7f0097fbd874bf18497e4c78287a68ce9d007aac7e0
data/README.md CHANGED
@@ -40,9 +40,12 @@ This code is equivalent to the following code.
40
40
 
41
41
  ```ruby
42
42
  require 'gc_tracer'
43
- GC::Tracer.start_logging(filename)
44
- # do something
45
- GC::Tracer.stop_logging
43
+ begin
44
+ GC::Tracer.start_logging(filename)
45
+ # do something
46
+ ensure
47
+ GC::Tracer.stop_logging
48
+ end
46
49
  ```
47
50
 
48
51
  In the stored file (filename), you can get tab separated values of:
@@ -3,6 +3,8 @@ require 'mkmf'
3
3
  # auto generation script
4
4
  rusage_members = []
5
5
 
6
+ have_func("rb_obj_gc_flags", "ruby/ruby.h");
7
+
6
8
  if try_link(%q{
7
9
  #include "ruby/ruby.h"
8
10
  void rb_objspace_each_objects_without_setup(int (*callback)(void *, void *, size_t, void *), void *data);
@@ -543,28 +543,49 @@ categorical_color20(int n)
543
543
 
544
544
  static struct picker_description object_age_picker_description[] = {
545
545
  {"empty slot", 0},
546
- {"old slot", 0x1f77b4},
546
+ {"infant slot", 0x1f77b4},
547
547
  {"young slot", 0xff7f0e},
548
- {"shady slot", 0x2ca02c}
548
+ {"old slot", 0x2ca02c},
549
+ {"shady slot", 0xd62728}
549
550
  };
550
551
 
552
+ #ifdef HAVE_RB_OBJ_GC_FLAGS
553
+ size_t rb_obj_gc_flags(VALUE obj, ID* flags, size_t max);
554
+ static ID id_young;
555
+ #endif
556
+
551
557
  static int
552
558
  object_age_picker(VALUE v) {
553
559
  if (RB_TYPE_P(v, T_NONE)) {
554
560
  return 0;
555
561
  }
556
562
  else {
557
- if (OBJ_PROMOTED(v)) {
558
- /* old */
559
- return categorical_color10(0);
563
+ if (!OBJ_PROMOTED(v)) {
564
+ if (OBJ_WB_PROTECTED(v)) {
565
+ return categorical_color10(0); /* infant */
566
+ }
567
+ else {
568
+ return categorical_color10(3); /* shady */
569
+ }
560
570
  }
561
571
  else {
562
- if (OBJ_WB_PROTECTED(v)) {
563
- /* young */
564
- return categorical_color10(1);
572
+ int is_young = 0;
573
+ #ifdef HAVE_RB_OBJ_GC_FLAGS
574
+ ID ids[8];
575
+ size_t i, count = rb_obj_gc_flags(v, ids, 8);
576
+
577
+ for (i=0; i<count; i++) {
578
+ if (ids[i] == id_young) {
579
+ is_young = 1;
580
+ break;
581
+ }
582
+ }
583
+ #endif
584
+ if (is_young) {
585
+ return categorical_color10(1); /* young */
565
586
  }
566
587
  else {
567
- return categorical_color10(2);
588
+ return categorical_color10(2); /* old */
568
589
  }
569
590
  }
570
591
  }
@@ -817,7 +838,13 @@ Init_gc_tracer(void)
817
838
  /* setup default banners */
818
839
  setup_gc_trace_symbols();
819
840
  start_tick = tick();
820
- rb_gc_latest_gc_info(ID2SYM(rb_intern("gc_by"))); /* warm up */
841
+
842
+ /* warm up */
843
+ rb_gc_latest_gc_info(ID2SYM(rb_intern("gc_by")));
844
+ #if HAVE_RB_OBJ_GC_FLAGS
845
+ rb_obj_gc_flags(rb_cObject, NULL, 0);
846
+ id_young = rb_intern("young");
847
+ #endif
821
848
 
822
849
  gc_trace_items = rb_ary_new();
823
850
  gc_trace_items_types = rb_ary_new();
@@ -1,3 +1,3 @@
1
1
  module GC::Tracer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gc_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler