io-event 1.8.0 → 1.8.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/io/event/profile.c +41 -53
- data/ext/io/event/profile.h +6 -5
- data/ext/io/event/selector/kqueue.c +2 -2
- data/lib/io/event/version.rb +1 -1
- 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: 9b0f569ddbe799cd62297cbe404f9799a5354cdb8a29bf0e75c2ae566bedc1fa
|
4
|
+
data.tar.gz: dc7c358d32584e3f83bf13e4457e556606f38a8084408273b01e9cb5763284e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358ccfbdcf25cd12731e6f98583db917207411db261d69c5ed2adf3c3c4f84fcb6e572d7029365bb82c501b00c68d9af3726cbb74d3983e44b189d7d362eb147
|
7
|
+
data.tar.gz: 63a5a659138caebfcd0fa8ebc08235127d556dc4c16d0e73f70613b360e702bc73f458156c40f79afdb2f93378e40859fd10c7be0df3e4cc7a355d29b8501325
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/io/event/profile.c
CHANGED
@@ -8,9 +8,12 @@
|
|
8
8
|
|
9
9
|
#include <stdio.h>
|
10
10
|
|
11
|
-
void
|
12
|
-
event->
|
13
|
-
event->
|
11
|
+
void IO_Event_Profile_Call_initialize(struct IO_Event_Profile_Call *event) {
|
12
|
+
event->enter_time.tv_sec = 0;
|
13
|
+
event->enter_time.tv_nsec = 0;
|
14
|
+
event->exit_time.tv_sec = 0;
|
15
|
+
event->exit_time.tv_nsec = 0;
|
16
|
+
|
14
17
|
event->nesting = 0;
|
15
18
|
|
16
19
|
event->event_flag = 0;
|
@@ -20,27 +23,12 @@ void IO_Event_Profile_Event_initialize(struct IO_Event_Profile_Event *event) {
|
|
20
23
|
event->line = 0;
|
21
24
|
}
|
22
25
|
|
23
|
-
void
|
26
|
+
void IO_Event_Profile_Call_free(struct IO_Event_Profile_Call *event) {
|
24
27
|
if (event->path) {
|
25
28
|
free((void*)event->path);
|
26
29
|
}
|
27
30
|
}
|
28
31
|
|
29
|
-
static const char *event_flag_name(rb_event_flag_t event_flag) {
|
30
|
-
switch (event_flag) {
|
31
|
-
case RUBY_EVENT_LINE:
|
32
|
-
return "line";
|
33
|
-
case RUBY_EVENT_CALL:
|
34
|
-
case RUBY_EVENT_C_CALL:
|
35
|
-
return "call";
|
36
|
-
case RUBY_EVENT_RETURN:
|
37
|
-
case RUBY_EVENT_C_RETURN:
|
38
|
-
return "return";
|
39
|
-
default:
|
40
|
-
return "unknown";
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
32
|
int event_flag_call_p(rb_event_flag_t event_flags) {
|
45
33
|
return event_flags & (RUBY_EVENT_CALL | RUBY_EVENT_C_CALL);
|
46
34
|
}
|
@@ -51,13 +39,13 @@ int event_flag_return_p(rb_event_flag_t event_flags) {
|
|
51
39
|
|
52
40
|
static void profile_event_callback(rb_event_flag_t event_flag, VALUE data, VALUE self, ID id, VALUE klass) {
|
53
41
|
struct IO_Event_Profile *profile = (struct IO_Event_Profile*)data;
|
54
|
-
struct IO_Event_Profile_Event *event = IO_Event_Array_push(&profile->events);
|
55
|
-
|
56
|
-
IO_Event_Time_current(&event->time);
|
57
|
-
|
58
|
-
event->event_flag = event_flag;
|
59
42
|
|
60
43
|
if (event_flag_call_p(event_flag)) {
|
44
|
+
struct IO_Event_Profile_Call *event = IO_Event_Array_push(&profile->events);
|
45
|
+
IO_Event_Time_current(&event->enter_time);
|
46
|
+
|
47
|
+
event->event_flag = event_flag;
|
48
|
+
|
61
49
|
event->parent = profile->current;
|
62
50
|
profile->current = event;
|
63
51
|
|
@@ -77,25 +65,25 @@ static void profile_event_callback(rb_event_flag_t event_flag, VALUE data, VALUE
|
|
77
65
|
}
|
78
66
|
event->line = rb_sourceline();
|
79
67
|
} else if (event_flag_return_p(event_flag)) {
|
80
|
-
|
81
|
-
profile->current->pair = event;
|
82
|
-
event->pair = profile->current;
|
68
|
+
struct IO_Event_Profile_Call *event = profile->current;
|
83
69
|
|
84
|
-
|
85
|
-
event
|
70
|
+
// Bad event sequence?
|
71
|
+
if (event == NULL) return;
|
86
72
|
|
73
|
+
IO_Event_Time_current(&event->exit_time);
|
74
|
+
|
75
|
+
profile->current = event->parent;
|
87
76
|
profile->nesting -= 1;
|
88
|
-
event->nesting = profile->nesting;
|
89
77
|
}
|
90
78
|
}
|
91
79
|
|
92
80
|
void IO_Event_Profile_initialize(struct IO_Event_Profile *profile, VALUE fiber) {
|
93
81
|
profile->fiber = fiber;
|
94
82
|
|
95
|
-
profile->events.element_initialize = (void (*)(void*))
|
96
|
-
profile->events.element_free = (void (*)(void*))
|
83
|
+
profile->events.element_initialize = (void (*)(void*))IO_Event_Profile_Call_initialize;
|
84
|
+
profile->events.element_free = (void (*)(void*))IO_Event_Profile_Call_free;
|
97
85
|
|
98
|
-
IO_Event_Array_initialize(&profile->events, 0, sizeof(struct
|
86
|
+
IO_Event_Array_initialize(&profile->events, 0, sizeof(struct IO_Event_Profile_Call));
|
99
87
|
}
|
100
88
|
|
101
89
|
void IO_Event_Profile_start(struct IO_Event_Profile *profile) {
|
@@ -128,27 +116,27 @@ void IO_Event_Profile_print(FILE *restrict stream, struct IO_Event_Profile *prof
|
|
128
116
|
size_t skipped = 0;
|
129
117
|
|
130
118
|
for (size_t i = 0; i < profile->events.limit; i += 1) {
|
131
|
-
struct
|
119
|
+
struct IO_Event_Profile_Call *event = profile->events.base[i];
|
120
|
+
|
121
|
+
struct timespec duration = {};
|
132
122
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
// Skip events that are too short to be meaningful:
|
140
|
-
if (IO_Event_Time_proportion(&duration, &total_duration) < IO_EVENT_PROFILE_PRINT_MINIMUM_PROPORTION) {
|
141
|
-
skipped += 1;
|
142
|
-
continue;
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
for (size_t i = 0; i < event->nesting; i += 1) {
|
147
|
-
fputc('\t', stream);
|
148
|
-
}
|
149
|
-
|
150
|
-
const char *name = rb_id2name(event->id);
|
151
|
-
fprintf(stream, "\t%s:%d in '%s#%s' (" IO_EVENT_TIME_PRINTF_TIMESPEC "s)\n", event->path, event->line, RSTRING_PTR(rb_inspect(event->klass)), name, IO_EVENT_TIME_PRINTF_TIMESPEC_ARGUMENTS(duration));
|
123
|
+
IO_Event_Time_elapsed(&event->enter_time, &event->exit_time, &duration);
|
124
|
+
|
125
|
+
// Skip events that are too short to be meaningful:
|
126
|
+
if (IO_Event_Time_proportion(&duration, &total_duration) < IO_EVENT_PROFILE_PRINT_MINIMUM_PROPORTION) {
|
127
|
+
skipped += 1;
|
128
|
+
continue;
|
152
129
|
}
|
130
|
+
|
131
|
+
for (size_t i = 0; i < event->nesting; i += 1) {
|
132
|
+
fputc('\t', stream);
|
133
|
+
}
|
134
|
+
|
135
|
+
const char *name = rb_id2name(event->id);
|
136
|
+
fprintf(stream, "\t%s:%d in '%s#%s' (" IO_EVENT_TIME_PRINTF_TIMESPEC "s)\n", event->path, event->line, RSTRING_PTR(rb_inspect(event->klass)), name, IO_EVENT_TIME_PRINTF_TIMESPEC_ARGUMENTS(duration));
|
137
|
+
}
|
138
|
+
|
139
|
+
if (skipped > 0) {
|
140
|
+
fprintf(stream, "Skipped %zu events that were too short to be meaningful.\n", skipped);
|
153
141
|
}
|
154
142
|
}
|
data/ext/io/event/profile.h
CHANGED
@@ -7,8 +7,10 @@
|
|
7
7
|
#include "array.h"
|
8
8
|
#include "time.h"
|
9
9
|
|
10
|
-
struct
|
11
|
-
struct timespec
|
10
|
+
struct IO_Event_Profile_Call {
|
11
|
+
struct timespec enter_time;
|
12
|
+
struct timespec exit_time;
|
13
|
+
|
12
14
|
size_t nesting;
|
13
15
|
|
14
16
|
rb_event_flag_t event_flag;
|
@@ -18,8 +20,7 @@ struct IO_Event_Profile_Event {
|
|
18
20
|
const char *path;
|
19
21
|
int line;
|
20
22
|
|
21
|
-
struct
|
22
|
-
struct IO_Event_Profile_Event *pair;
|
23
|
+
struct IO_Event_Profile_Call *parent;
|
23
24
|
};
|
24
25
|
|
25
26
|
struct IO_Event_Profile {
|
@@ -32,7 +33,7 @@ struct IO_Event_Profile {
|
|
32
33
|
size_t nesting;
|
33
34
|
|
34
35
|
// The current call frame:
|
35
|
-
struct
|
36
|
+
struct IO_Event_Profile_Call *current;
|
36
37
|
|
37
38
|
struct IO_Event_Array events;
|
38
39
|
};
|
@@ -975,7 +975,7 @@ VALUE IO_Event_Selector_KQueue_select(VALUE self, VALUE duration) {
|
|
975
975
|
// Non-comprehensive testing shows this gives a 1.5x speedup.
|
976
976
|
|
977
977
|
// First do the syscall with no timeout to get any immediately available events:
|
978
|
-
if (DEBUG) fprintf(stderr, "\r\nselect_internal_with_gvl timeout="
|
978
|
+
if (DEBUG) fprintf(stderr, "\r\nselect_internal_with_gvl timeout=" IO_EVENT_TIME_PRINTF_TIMESPEC "\r\n", IO_EVENT_TIME_PRINTF_TIMESPEC_ARGUMENTS(arguments.storage));
|
979
979
|
select_internal_with_gvl(&arguments);
|
980
980
|
if (DEBUG) fprintf(stderr, "\r\nselect_internal_with_gvl done\r\n");
|
981
981
|
|
@@ -993,7 +993,7 @@ VALUE IO_Event_Selector_KQueue_select(VALUE self, VALUE duration) {
|
|
993
993
|
struct timespec start_time;
|
994
994
|
IO_Event_Time_current(&start_time);
|
995
995
|
|
996
|
-
if (DEBUG) fprintf(stderr, "IO_Event_Selector_KQueue_select timeout="
|
996
|
+
if (DEBUG) fprintf(stderr, "IO_Event_Selector_KQueue_select timeout=" IO_EVENT_TIME_PRINTF_TIMESPEC "\n", IO_EVENT_TIME_PRINTF_TIMESPEC_ARGUMENTS(arguments.storage));
|
997
997
|
select_internal_without_gvl(&arguments);
|
998
998
|
|
999
999
|
struct timespec end_time;
|
data/lib/io/event/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|