prometheus-client-mmap 0.21.0-x86_64-linux-musl → 1.2.1-x86_64-linux-musl

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.tool-versions +1 -0
  3. data/README.md +32 -17
  4. data/ext/fast_mmaped_file_rs/Cargo.toml +14 -9
  5. data/ext/fast_mmaped_file_rs/build.rs +5 -0
  6. data/ext/fast_mmaped_file_rs/extconf.rb +1 -3
  7. data/ext/fast_mmaped_file_rs/src/error.rs +2 -2
  8. data/ext/fast_mmaped_file_rs/src/file_entry.rs +222 -17
  9. data/ext/fast_mmaped_file_rs/src/file_info.rs +56 -6
  10. data/ext/fast_mmaped_file_rs/src/lib.rs +0 -1
  11. data/ext/fast_mmaped_file_rs/src/map.rs +12 -12
  12. data/ext/fast_mmaped_file_rs/src/mmap/inner.rs +704 -0
  13. data/ext/fast_mmaped_file_rs/src/mmap.rs +765 -25
  14. data/ext/fast_mmaped_file_rs/src/raw_entry.rs +1 -1
  15. data/ext/fast_mmaped_file_rs/src/testhelper.rs +1 -1
  16. data/lib/3.1/fast_mmaped_file_rs.so +0 -0
  17. data/lib/3.2/fast_mmaped_file_rs.so +0 -0
  18. data/lib/3.3/fast_mmaped_file_rs.so +0 -0
  19. data/lib/3.4/fast_mmaped_file_rs.so +0 -0
  20. data/lib/prometheus/client/formats/text.rb +1 -34
  21. data/lib/prometheus/client/helper/mmaped_file.rb +3 -3
  22. data/lib/prometheus/client/label_set_validator.rb +1 -2
  23. data/lib/prometheus/client/support/puma.rb +44 -0
  24. data/lib/prometheus/client/version.rb +1 -1
  25. metadata +67 -61
  26. data/ext/fast_mmaped_file/extconf.rb +0 -30
  27. data/ext/fast_mmaped_file/fast_mmaped_file.c +0 -122
  28. data/ext/fast_mmaped_file/file_format.c +0 -5
  29. data/ext/fast_mmaped_file/file_format.h +0 -11
  30. data/ext/fast_mmaped_file/file_parsing.c +0 -195
  31. data/ext/fast_mmaped_file/file_parsing.h +0 -27
  32. data/ext/fast_mmaped_file/file_reading.c +0 -102
  33. data/ext/fast_mmaped_file/file_reading.h +0 -30
  34. data/ext/fast_mmaped_file/globals.h +0 -14
  35. data/ext/fast_mmaped_file/mmap.c +0 -427
  36. data/ext/fast_mmaped_file/mmap.h +0 -61
  37. data/ext/fast_mmaped_file/rendering.c +0 -199
  38. data/ext/fast_mmaped_file/rendering.h +0 -8
  39. data/ext/fast_mmaped_file/utils.c +0 -56
  40. data/ext/fast_mmaped_file/utils.h +0 -22
  41. data/ext/fast_mmaped_file/value_access.c +0 -242
  42. data/ext/fast_mmaped_file/value_access.h +0 -15
  43. data/ext/fast_mmaped_file_rs/.cargo/config.toml +0 -23
  44. data/ext/fast_mmaped_file_rs/Cargo.lock +0 -790
  45. data/ext/fast_mmaped_file_rs/src/parser.rs +0 -346
  46. data/lib/2.7/fast_mmaped_file.so +0 -0
  47. data/lib/2.7/fast_mmaped_file_rs.so +0 -0
  48. data/lib/3.0/fast_mmaped_file.so +0 -0
  49. data/lib/3.0/fast_mmaped_file_rs.so +0 -0
  50. data/lib/3.1/fast_mmaped_file.so +0 -0
  51. data/lib/3.2/fast_mmaped_file.so +0 -0
  52. data/vendor/c/hashmap/.gitignore +0 -52
  53. data/vendor/c/hashmap/LICENSE +0 -21
  54. data/vendor/c/hashmap/README.md +0 -90
  55. data/vendor/c/hashmap/_config.yml +0 -1
  56. data/vendor/c/hashmap/src/hashmap.c +0 -692
  57. data/vendor/c/hashmap/src/hashmap.h +0 -267
  58. data/vendor/c/hashmap/test/Makefile +0 -22
  59. data/vendor/c/hashmap/test/hashmap_test.c +0 -608
  60. data/vendor/c/jsmn/.travis.yml +0 -4
  61. data/vendor/c/jsmn/LICENSE +0 -20
  62. data/vendor/c/jsmn/Makefile +0 -41
  63. data/vendor/c/jsmn/README.md +0 -168
  64. data/vendor/c/jsmn/example/jsondump.c +0 -126
  65. data/vendor/c/jsmn/example/simple.c +0 -76
  66. data/vendor/c/jsmn/jsmn.c +0 -314
  67. data/vendor/c/jsmn/jsmn.h +0 -76
  68. data/vendor/c/jsmn/library.json +0 -16
  69. data/vendor/c/jsmn/test/test.h +0 -27
  70. data/vendor/c/jsmn/test/tests.c +0 -407
  71. data/vendor/c/jsmn/test/testutil.h +0 -94
@@ -1,56 +0,0 @@
1
- #include "utils.h"
2
-
3
- #include <errno.h>
4
-
5
- static void rb_save_exception(VALUE exception, VALUE message) {
6
- VALUE current_thread = rb_thread_current();
7
-
8
- rb_thread_local_aset(current_thread, rb_intern("prometheus_last_exception"), exception);
9
- rb_thread_local_aset(current_thread, rb_intern("prometheus_last_exception_message"), message);
10
- }
11
- /* @deprecated - use with_exception ignoring return value */
12
- void save_exception(VALUE exception, const char *fmt, ...) {
13
- va_list args;
14
-
15
- va_start(args, fmt);
16
- VALUE message = rb_vsprintf(fmt, args);
17
-
18
- rb_save_exception(exception, message);
19
- va_end(args);
20
- }
21
-
22
- int with_exception(VALUE exception, const char *fmt, ...) {
23
- va_list args;
24
-
25
- va_start(args, fmt);
26
- VALUE message = rb_vsprintf(fmt, args);
27
-
28
- rb_save_exception(exception, message);
29
- va_end(args);
30
-
31
- return FAILURE;
32
- }
33
-
34
- int with_exception_errno(VALUE exception, const char *fmt, ...) {
35
- va_list args;
36
-
37
- va_start(args, fmt);
38
- VALUE message = rb_vsprintf(fmt, args);
39
- rb_str_catf(message, " (%s)", strerror(errno));
40
-
41
- rb_save_exception(exception, message);
42
- va_end(args);
43
-
44
- return FAILURE;
45
- }
46
-
47
- NORETURN(void raise_last_exception()) {
48
- VALUE current_thread = rb_thread_current();
49
- VALUE exception = rb_thread_local_aref(current_thread, rb_intern("prometheus_last_exception"));
50
- VALUE message = rb_thread_local_aref(current_thread, rb_intern("prometheus_last_exception_message"));
51
- if (exception != Qnil) {
52
- rb_raise(exception, "%s", StringValueCStr(message));
53
- } else {
54
- rb_raise(rb_eRuntimeError, "no exception found in thread local");
55
- }
56
- }
@@ -1,22 +0,0 @@
1
- #ifndef UNUSED_H
2
- #define UNUSED_H
3
- #include <ruby.h>
4
-
5
- #ifdef UNUSED
6
- #elif defined(__GNUC__)
7
- #define UNUSED(x) UNUSED_##x __attribute__((unused))
8
- #elif defined(__LCLINT__)
9
- #define UNUSED(x) /*@unused@*/ x
10
- #else
11
- #define UNUSED(x) x
12
- #endif
13
-
14
- #define SUCCESS 1
15
- #define FAILURE 0
16
-
17
- NORETURN(void raise_last_exception());
18
- void save_exception(VALUE exception, const char *fmt, ...);
19
- int with_exception(VALUE exception, const char *fmt, ...);
20
- int with_exception_errno(VALUE exception, const char *fmt, ...);
21
-
22
- #endif
@@ -1,242 +0,0 @@
1
- #include "value_access.h"
2
-
3
- #include <errno.h>
4
- #include <fcntl.h>
5
- #include <ruby/intern.h>
6
- #include <sys/mman.h>
7
- #include <unistd.h>
8
-
9
- #include "file_format.h"
10
- #include "mmap.h"
11
- #include "utils.h"
12
-
13
- static void close_file(mm_ipc *i_mm) {
14
- close(i_mm->t->fd);
15
- i_mm->t->fd = -1;
16
- }
17
-
18
- static int open_and_extend_file(mm_ipc *i_mm, size_t len) {
19
- if (i_mm->t->fd < 0) {
20
- int fd;
21
-
22
- if ((fd = open(i_mm->t->path, i_mm->t->smode)) == -1) {
23
- return with_exception_errno(rb_eArgError, "%s: Can't open %s", __FILE__, i_mm->t->path);
24
- }
25
- i_mm->t->fd = fd;
26
- }
27
-
28
- if (lseek(i_mm->t->fd, len - 1, SEEK_SET) == -1) {
29
- close_file(i_mm);
30
- return with_exception_errno(rb_eIOError, "Can't lseek %zu", len - 1);
31
- }
32
-
33
- if (write(i_mm->t->fd, "\000", 1) != 1) {
34
- close_file(i_mm);
35
- return with_exception_errno(rb_eIOError, "Can't extend %s", i_mm->t->path);
36
- }
37
- i_mm->t->len = len;
38
-
39
- return SUCCESS;
40
- }
41
-
42
- static int perform_munmap(mm_ipc *i_mm) {
43
- if (i_mm->t->addr != NULL && munmap(i_mm->t->addr, i_mm->t->len)) {
44
- i_mm->t->addr = NULL;
45
- return with_exception_errno(rb_eArgError, "munmap failed");
46
- }
47
-
48
- i_mm->t->addr = NULL;
49
- i_mm->t->len = 0;
50
- i_mm->t->real = 0;
51
-
52
- return SUCCESS;
53
- }
54
-
55
- static int perform_mmap(mm_ipc *i_mm, size_t len) {
56
- MMAP_RETTYPE addr = mmap(0, len, i_mm->t->pmode, i_mm->t->vscope, i_mm->t->fd, i_mm->t->offset);
57
-
58
- if (addr == MAP_FAILED) {
59
- return with_exception_errno(rb_eArgError, "mmap failed");
60
- }
61
-
62
- i_mm->t->addr = addr;
63
- i_mm->t->len = len;
64
- i_mm->t->real = len;
65
-
66
- return SUCCESS;
67
- }
68
-
69
- static int expand(VALUE self, mm_ipc *i_mm, size_t len) {
70
- if (len < i_mm->t->len) {
71
- return with_exception(rb_eArgError, "Can't reduce the size of mmap");
72
- }
73
-
74
- if (!perform_munmap(i_mm)) {
75
- return FAILURE;
76
- }
77
-
78
- if (!open_and_extend_file(i_mm, len)) {
79
- return FAILURE;
80
- }
81
-
82
- if (!perform_mmap(i_mm, len)) {
83
- close_file(i_mm);
84
- return FAILURE;
85
- }
86
-
87
- if ((i_mm->t->flag & MM_LOCK) && mlock(i_mm->t->addr, len) == -1) {
88
- return with_exception_errno(rb_eArgError, "mlock(%d)", errno);
89
- }
90
-
91
- mm_update(self);
92
-
93
- return SUCCESS;
94
- }
95
-
96
- static void save_entry(mm_ipc *i_mm, size_t offset, VALUE key, VALUE value) {
97
- uint32_t key_length = (uint32_t)RSTRING_LEN(key);
98
-
99
- char *pos = (char *)i_mm->t->addr + offset;
100
-
101
- memcpy(pos, &key_length, sizeof(uint32_t));
102
- pos += sizeof(uint32_t);
103
-
104
- memmove(pos, StringValuePtr(key), key_length);
105
- pos += key_length;
106
-
107
- memset(pos, ' ', padding_length(key_length)); // TODO: considder padding with /0
108
- pos += padding_length(key_length);
109
-
110
- double val = NUM2DBL(value);
111
- memcpy(pos, &val, sizeof(double));
112
- }
113
-
114
- static void save_value(mm_ipc *i_mm, VALUE _offset, VALUE value) {
115
- Check_Type(_offset, T_FIXNUM);
116
- size_t offset = NUM2UINT(_offset);
117
- if ((i_mm->t->real + sizeof(double)) <= offset) {
118
- rb_raise(rb_eIndexError, "offset %zu out of string", offset);
119
- }
120
-
121
- if (i_mm->t->flag & MM_FROZEN) {
122
- rb_error_frozen("mmap");
123
- }
124
-
125
- char *pos = (char *)i_mm->t->addr + offset;
126
-
127
- double val = NUM2DBL(value);
128
- memcpy(pos, &val, sizeof(double));
129
- }
130
-
131
- static VALUE load_value(mm_ipc *i_mm, VALUE _offset) {
132
- Check_Type(_offset, T_FIXNUM);
133
- size_t offset = NUM2UINT(_offset);
134
- if ((i_mm->t->real + sizeof(double)) <= offset) {
135
- rb_raise(rb_eIndexError, "offset %zu out of string", offset);
136
- }
137
-
138
- char *pos = (char *)i_mm->t->addr + offset;
139
-
140
- double value;
141
- memcpy(&value, pos, sizeof(double));
142
- return DBL2NUM(value);
143
- }
144
-
145
- uint32_t load_used(mm_ipc *i_mm) {
146
- uint32_t used = *((uint32_t *)i_mm->t->addr);
147
-
148
- if (used == 0) {
149
- used = START_POSITION;
150
- }
151
- return used;
152
- }
153
-
154
- void save_used(mm_ipc *i_mm, uint32_t used) { *((uint32_t *)i_mm->t->addr) = used; }
155
-
156
- static VALUE initialize_entry(VALUE self, mm_ipc *i_mm, VALUE positions, VALUE key, VALUE value) {
157
- if (i_mm->t->flag & MM_FROZEN) {
158
- rb_error_frozen("mmap");
159
- }
160
-
161
- if (RSTRING_LEN(key) > INT32_MAX) {
162
- rb_raise(rb_eArgError, "string length gt %d", INT32_MAX);
163
- }
164
-
165
- uint32_t key_length = (uint32_t)RSTRING_LEN(key);
166
- uint32_t value_offset = sizeof(uint32_t) + key_length + padding_length(key_length);
167
- uint32_t entry_length = value_offset + sizeof(double);
168
-
169
- uint32_t used = load_used(i_mm);
170
- while (i_mm->t->len < (used + entry_length)) {
171
- if (!expand(self, i_mm, i_mm->t->len * 2)) {
172
- raise_last_exception();
173
- }
174
- }
175
-
176
- save_entry(i_mm, used, key, value);
177
- save_used(i_mm, used + entry_length);
178
-
179
- return rb_hash_aset(positions, key, INT2NUM(used + value_offset));
180
- }
181
-
182
- VALUE method_fetch_entry(VALUE self, VALUE positions, VALUE key, VALUE default_value) {
183
- Check_Type(positions, T_HASH);
184
- Check_Type(key, T_STRING);
185
-
186
- mm_ipc *i_mm;
187
- GET_MMAP(self, i_mm, MM_MODIFY);
188
-
189
- VALUE position = rb_hash_lookup(positions, key);
190
-
191
- if (position != Qnil) {
192
- return load_value(i_mm, position);
193
- }
194
-
195
- position = initialize_entry(self, i_mm, positions, key, default_value);
196
- return load_value(i_mm, position);
197
- }
198
-
199
- VALUE method_upsert_entry(VALUE self, VALUE positions, VALUE key, VALUE value) {
200
- Check_Type(positions, T_HASH);
201
- Check_Type(key, T_STRING);
202
-
203
- mm_ipc *i_mm;
204
- GET_MMAP(self, i_mm, MM_MODIFY);
205
-
206
- VALUE position = rb_hash_lookup(positions, key);
207
-
208
- if (position != Qnil) {
209
- save_value(i_mm, position, value);
210
- return load_value(i_mm, position);
211
- }
212
-
213
- position = initialize_entry(self, i_mm, positions, key, value);
214
- return load_value(i_mm, position);
215
- }
216
-
217
- VALUE method_load_used(VALUE self) {
218
- mm_ipc *i_mm;
219
-
220
- GET_MMAP(self, i_mm, MM_MODIFY);
221
- return UINT2NUM(load_used(i_mm));
222
- }
223
-
224
- VALUE method_save_used(VALUE self, VALUE value) {
225
- Check_Type(value, T_FIXNUM);
226
- mm_ipc *i_mm;
227
-
228
- GET_MMAP(self, i_mm, MM_MODIFY);
229
-
230
- if (i_mm->t->flag & MM_FROZEN) {
231
- rb_error_frozen("mmap");
232
- }
233
-
234
- if (i_mm->t->len < INITIAL_SIZE) {
235
- if (!expand(self, i_mm, INITIAL_SIZE)) {
236
- raise_last_exception();
237
- }
238
- }
239
-
240
- save_used(i_mm, NUM2UINT(value));
241
- return value;
242
- }
@@ -1,15 +0,0 @@
1
- #ifndef VALUE_ACCESS_H
2
- #define VALUE_ACCESS_H
3
- #include <ruby.h>
4
-
5
- VALUE method_load_used(VALUE self);
6
-
7
- VALUE method_save_used(VALUE self, VALUE value);
8
-
9
- VALUE method_get_double(VALUE self, VALUE index);
10
-
11
- VALUE method_fetch_entry(VALUE self, VALUE positions, VALUE key, VALUE default_value);
12
-
13
- VALUE method_upsert_entry(VALUE self, VALUE positions, VALUE key, VALUE value);
14
-
15
- #endif
@@ -1,23 +0,0 @@
1
- [target.aarch64-apple-darwin]
2
- # Without this flag, when linking static libruby, the linker removes symbols
3
- # (such as `_rb_ext_ractor_safe`) which it thinks are dead code... but they are
4
- # not, and they need to be included for the `embed` feature to work with static
5
- # Ruby.
6
- rustflags = [
7
- "-C", "link-dead-code=on",
8
- "-C", "link-arg=-undefined",
9
- "-C", "link-arg=dynamic_lookup",
10
- ]
11
-
12
- [target.x86_64-apple-darwin]
13
- rustflags = [
14
- "-C", "link-dead-code=on",
15
- "-C", "link-arg=-undefined",
16
- "-C", "link-arg=dynamic_lookup",
17
- ]
18
-
19
- [target.aarch64-unknown-linux-gnu]
20
- rustflags = [ "-C", "link-dead-code=on" ]
21
-
22
- [target.x86_64-unknown-linux-gnu]
23
- rustflags = [ "-C", "link-dead-code=on" ]