memory-profiler 1.1.6 → 1.1.7
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
- checksums.yaml.gz.sig +0 -0
- data/ext/memory/profiler/capture.c +52 -0
- data/lib/memory/profiler/sampler.rb +24 -2
- data/lib/memory/profiler/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bb750e881686089136fbcd20b073e857dc3a7dc7f4784f0a75cf8fbb17444ec
|
|
4
|
+
data.tar.gz: 75d398699455359a70dafbbd1c71ce8dd529faf492f8fd7f595cc9714101061f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83261c47a3365c107239cd626b61afe496e51d17e04ee36ac81235d7493997089fd97648965af42747ff1b3f8074f1fe72df31a1ecf6ce774fe9ac1ae2cf0565
|
|
7
|
+
data.tar.gz: 5bf3be79ccabbc16f1d753c94a3af7d89affabfc34d4feb9fd001f0573cf516614363f7430dfbe3553166076c349ffe38cee7e39309f9f6eecef867ba4978d78
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -694,6 +694,57 @@ static VALUE Memory_Profiler_Capture_aref(VALUE self, VALUE klass) {
|
|
|
694
694
|
return Qnil;
|
|
695
695
|
}
|
|
696
696
|
|
|
697
|
+
// Struct to accumulate statistics during iteration
|
|
698
|
+
struct Memory_Profiler_Allocations_Statistics {
|
|
699
|
+
size_t total_tracked_objects;
|
|
700
|
+
VALUE per_class_counts;
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
// Iterator callback to count object_states per class
|
|
704
|
+
static int Memory_Profiler_Capture_count_object_states(st_data_t key, st_data_t value, st_data_t argument) {
|
|
705
|
+
struct Memory_Profiler_Allocations_Statistics *statistics = (struct Memory_Profiler_Allocations_Statistics *)argument;
|
|
706
|
+
VALUE klass = (VALUE)key;
|
|
707
|
+
VALUE allocations = (VALUE)value;
|
|
708
|
+
struct Memory_Profiler_Capture_Allocations *record = Memory_Profiler_Allocations_get(allocations);
|
|
709
|
+
|
|
710
|
+
size_t object_states_count = record->object_states ? record->object_states->num_entries : 0;
|
|
711
|
+
statistics->total_tracked_objects += object_states_count;
|
|
712
|
+
|
|
713
|
+
rb_hash_aset(statistics->per_class_counts, klass, SIZET2NUM(object_states_count));
|
|
714
|
+
return ST_CONTINUE;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// Get internal statistics for debugging
|
|
718
|
+
// Returns hash with internal state sizes
|
|
719
|
+
static VALUE Memory_Profiler_Capture_statistics(VALUE self) {
|
|
720
|
+
struct Memory_Profiler_Capture *capture;
|
|
721
|
+
TypedData_Get_Struct(self, struct Memory_Profiler_Capture, &Memory_Profiler_Capture_type, capture);
|
|
722
|
+
|
|
723
|
+
VALUE statistics = rb_hash_new();
|
|
724
|
+
|
|
725
|
+
// Tracked classes count
|
|
726
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("tracked_classes_count")), SIZET2NUM(capture->tracked_classes->num_entries));
|
|
727
|
+
|
|
728
|
+
// Queue sizes
|
|
729
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("newobj_queue_size")), SIZET2NUM(capture->newobj_queue.count));
|
|
730
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("newobj_queue_capacity")), SIZET2NUM(capture->newobj_queue.capacity));
|
|
731
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("freeobj_queue_size")), SIZET2NUM(capture->freeobj_queue.count));
|
|
732
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("freeobj_queue_capacity")), SIZET2NUM(capture->freeobj_queue.capacity));
|
|
733
|
+
|
|
734
|
+
// Count object_states entries for each tracked class
|
|
735
|
+
struct Memory_Profiler_Allocations_Statistics allocations_statistics = {
|
|
736
|
+
.total_tracked_objects = 0,
|
|
737
|
+
.per_class_counts = rb_hash_new()
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
st_foreach(capture->tracked_classes, Memory_Profiler_Capture_count_object_states, (st_data_t)&allocations_statistics);
|
|
741
|
+
|
|
742
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("total_tracked_objects")), SIZET2NUM(allocations_statistics.total_tracked_objects));
|
|
743
|
+
rb_hash_aset(statistics, ID2SYM(rb_intern("tracked_objects_per_class")), allocations_statistics.per_class_counts);
|
|
744
|
+
|
|
745
|
+
return statistics;
|
|
746
|
+
}
|
|
747
|
+
|
|
697
748
|
void Init_Memory_Profiler_Capture(VALUE Memory_Profiler)
|
|
698
749
|
{
|
|
699
750
|
// Initialize event symbols
|
|
@@ -715,6 +766,7 @@ void Init_Memory_Profiler_Capture(VALUE Memory_Profiler)
|
|
|
715
766
|
rb_define_method(Memory_Profiler_Capture, "each", Memory_Profiler_Capture_each, 0);
|
|
716
767
|
rb_define_method(Memory_Profiler_Capture, "[]", Memory_Profiler_Capture_aref, 1);
|
|
717
768
|
rb_define_method(Memory_Profiler_Capture, "clear", Memory_Profiler_Capture_clear, 0);
|
|
769
|
+
rb_define_method(Memory_Profiler_Capture, "statistics", Memory_Profiler_Capture_statistics, 0);
|
|
718
770
|
|
|
719
771
|
// Initialize Allocations class
|
|
720
772
|
Init_Memory_Profiler_Allocations(Memory_Profiler);
|
|
@@ -85,8 +85,6 @@ module Memory
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
attr_reader :depth
|
|
89
|
-
|
|
90
88
|
# Create a new memory sampler.
|
|
91
89
|
#
|
|
92
90
|
# @parameter depth [Integer] Number of stack frames to capture for call path analysis.
|
|
@@ -104,6 +102,30 @@ module Memory
|
|
|
104
102
|
@call_trees = {}
|
|
105
103
|
@samples = {}
|
|
106
104
|
end
|
|
105
|
+
|
|
106
|
+
# @attribute [Integer] The depth of the call tree.
|
|
107
|
+
attr :depth
|
|
108
|
+
|
|
109
|
+
# @attribute [Proc] The filter to exclude frames from call paths.
|
|
110
|
+
attr :filter
|
|
111
|
+
|
|
112
|
+
# @attribute [Integer] The number of increases before enabling detailed tracking.
|
|
113
|
+
attr :increases_threshold
|
|
114
|
+
|
|
115
|
+
# @attribute [Integer] The number of insertions before auto-pruning (nil = no auto-pruning).
|
|
116
|
+
attr :prune_limit
|
|
117
|
+
|
|
118
|
+
# @attribute [Integer | Nil] The number of insertions before auto-pruning (nil = no auto-pruning).
|
|
119
|
+
attr :prune_threshold
|
|
120
|
+
|
|
121
|
+
# @attribute [Capture] The capture object.
|
|
122
|
+
attr :capture
|
|
123
|
+
|
|
124
|
+
# @attribute [Hash] The call trees.
|
|
125
|
+
attr :call_trees
|
|
126
|
+
|
|
127
|
+
# @attribute [Hash] The samples for each class being tracked.
|
|
128
|
+
attr :samples
|
|
107
129
|
|
|
108
130
|
# Start capturing allocations.
|
|
109
131
|
def start
|
data/readme.md
CHANGED
|
@@ -22,6 +22,10 @@ Please see the [project documentation](https://socketry.github.io/memory-profile
|
|
|
22
22
|
|
|
23
23
|
Please see the [project releases](https://socketry.github.io/memory-profiler/releases/index) for all releases.
|
|
24
24
|
|
|
25
|
+
### v1.1.7
|
|
26
|
+
|
|
27
|
+
- Expose `Capture#statistics` for debugging internal memory tracking state.
|
|
28
|
+
|
|
25
29
|
### v1.1.6
|
|
26
30
|
|
|
27
31
|
- Write barriers all the things.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|