prometheus-client-mmap 0.24.5-aarch64-linux → 0.26.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -6
- data/ext/fast_mmaped_file/mmap.c +13 -2
- data/ext/fast_mmaped_file_rs/Cargo.lock +10 -8
- data/ext/fast_mmaped_file_rs/Cargo.toml +3 -0
- data/ext/fast_mmaped_file_rs/build.rs +5 -0
- data/ext/fast_mmaped_file_rs/src/mmap.rs +15 -6
- data/lib/2.7/fast_mmaped_file.so +0 -0
- data/lib/2.7/fast_mmaped_file_rs.so +0 -0
- data/lib/3.0/fast_mmaped_file.so +0 -0
- data/lib/3.0/fast_mmaped_file_rs.so +0 -0
- data/lib/3.1/fast_mmaped_file.so +0 -0
- data/lib/3.1/fast_mmaped_file_rs.so +0 -0
- data/lib/3.2/fast_mmaped_file.so +0 -0
- data/lib/3.2/fast_mmaped_file_rs.so +0 -0
- data/lib/prometheus/client/configuration.rb +1 -1
- data/lib/prometheus/client/formats/text.rb +1 -1
- data/lib/prometheus/client/helper/mmaped_file.rb +1 -1
- data/lib/prometheus/client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e35ca1ae2812cda0478763c3b997e29456538f2b43b6bcb4071a54b19053f84d
|
4
|
+
data.tar.gz: b3502b15d6ad72a96af6b05178acfc0f523b516936e0719e82577e1baebcd044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e5ec2f8db673963f7fabada53fba0fbba28181085012bf84e3cf6eaa66e8be957caa93b8dfeb2f6e6f2b0b5a2b058fe766903f1975d7e30eafdccd1d9fccbec
|
7
|
+
data.tar.gz: 1a44d4b0c13b5c8d7add56ad746fd495b0215bceb90837d36a275e5a3e7679bd85570e36b47ea14bc9040d605a3ade1b2feef5ff8eae1641c08402fd969147dc
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ http_requests = prometheus.counter(:http_requests, 'A counter of HTTP requests m
|
|
34
34
|
http_requests.increment
|
35
35
|
```
|
36
36
|
|
37
|
-
## Rust extension
|
37
|
+
## Rust extension
|
38
38
|
|
39
39
|
In an effort to improve maintainability, there is now an optional Rust
|
40
40
|
implementation that reads the metric files and outputs the multiprocess
|
@@ -202,14 +202,21 @@ prometheus_multiproc_dir=/tmp
|
|
202
202
|
|
203
203
|
### Multiprocess metrics via Rust extension
|
204
204
|
|
205
|
-
|
206
|
-
|
207
|
-
|
205
|
+
By default, the Rust extension will be used to read and write multiprocess
|
206
|
+
metrics if the `fast_mmaped_file_rs` extension is available. This should
|
207
|
+
be significantly faster than the C extension.
|
208
|
+
|
209
|
+
If the environment variable `prometheus_rust_multiprocess_metrics=false`
|
210
|
+
is set or if the `rust_multiprocess_metrics` configuration setting is
|
211
|
+
`false` , the C extension will be used.
|
208
212
|
|
209
213
|
### Read and write metrics via Rust extension
|
210
214
|
|
211
|
-
|
212
|
-
|
215
|
+
By default, the Rust extension will be used to read and write metrics
|
216
|
+
from the mmaped file if the `fast_mmaped_file_rs` extension is available.
|
217
|
+
|
218
|
+
To use the C extension, set the environment variable
|
219
|
+
`prometheus_rust_mmaped_file=false`.
|
213
220
|
|
214
221
|
## Pitfalls
|
215
222
|
|
data/ext/fast_mmaped_file/mmap.c
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
#include <errno.h>
|
4
4
|
#include <fcntl.h>
|
5
5
|
#include <ruby/util.h>
|
6
|
+
#include <ruby/version.h>
|
6
7
|
#include <sys/mman.h>
|
7
8
|
|
8
9
|
#include "file_format.h"
|
@@ -27,6 +28,16 @@
|
|
27
28
|
*/
|
28
29
|
static VALUE weak_obj_tracker_get_key(VALUE val) { return val; }
|
29
30
|
|
31
|
+
static void update_rstring_len(VALUE val, size_t len) {
|
32
|
+
#if defined(RUBY_API_VERSION_MAJOR) && defined(RUBY_API_VERSION_MINOR) && (RUBY_API_VERSION_MAJOR == 3) && \
|
33
|
+
(RUBY_API_VERSION_MINOR >= 3)
|
34
|
+
|
35
|
+
RSTRING(val)->len = len;
|
36
|
+
#else
|
37
|
+
RSTRING(val)->as.heap.len = len;
|
38
|
+
#endif
|
39
|
+
}
|
40
|
+
|
30
41
|
/**
|
31
42
|
* Adds a T_STRING type to the WeakMap. The WeakMap should be stored
|
32
43
|
* as an instance variable.
|
@@ -52,7 +63,7 @@ VALUE mm_update_obj_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, self)) {
|
|
52
63
|
GET_MMAP(self, i_mm, MM_MODIFY);
|
53
64
|
|
54
65
|
RSTRING(i)->as.heap.ptr = i_mm->t->addr;
|
55
|
-
|
66
|
+
update_rstring_len(i, i_mm->t->real);
|
56
67
|
|
57
68
|
return Qtrue;
|
58
69
|
}
|
@@ -98,7 +109,7 @@ static VALUE mm_str(VALUE obj, int modify) {
|
|
98
109
|
ret = rb_obj_alloc(rb_cString);
|
99
110
|
RSTRING(ret)->as.heap.ptr = i_mm->t->addr;
|
100
111
|
RSTRING(ret)->as.heap.aux.capa = i_mm->t->len;
|
101
|
-
|
112
|
+
update_rstring_len(ret, i_mm->t->real);
|
102
113
|
|
103
114
|
weak_obj_tracker_add(obj, ret);
|
104
115
|
|
@@ -30,9 +30,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|
30
30
|
|
31
31
|
[[package]]
|
32
32
|
name = "bindgen"
|
33
|
-
version = "0.
|
33
|
+
version = "0.62.0"
|
34
34
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
35
|
-
checksum = "
|
35
|
+
checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
|
36
36
|
dependencies = [
|
37
37
|
"bitflags",
|
38
38
|
"cexpr",
|
@@ -45,6 +45,7 @@ dependencies = [
|
|
45
45
|
"regex",
|
46
46
|
"rustc-hash",
|
47
47
|
"shlex",
|
48
|
+
"syn 1.0.109",
|
48
49
|
]
|
49
50
|
|
50
51
|
[[package]]
|
@@ -169,6 +170,7 @@ dependencies = [
|
|
169
170
|
"nix",
|
170
171
|
"rand",
|
171
172
|
"rb-sys",
|
173
|
+
"rb-sys-env",
|
172
174
|
"serde",
|
173
175
|
"serde_json",
|
174
176
|
"sha2",
|
@@ -297,7 +299,7 @@ checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f"
|
|
297
299
|
[[package]]
|
298
300
|
name = "magnus"
|
299
301
|
version = "0.5.0"
|
300
|
-
source = "git+https://github.com/matsadler/magnus?branch=main#
|
302
|
+
source = "git+https://github.com/matsadler/magnus?branch=main#50cab2380103c39c14765a10bdc4b38a74082285"
|
301
303
|
dependencies = [
|
302
304
|
"magnus-macros",
|
303
305
|
"rb-sys",
|
@@ -308,7 +310,7 @@ dependencies = [
|
|
308
310
|
[[package]]
|
309
311
|
name = "magnus-macros"
|
310
312
|
version = "0.4.0"
|
311
|
-
source = "git+https://github.com/matsadler/magnus?branch=main#
|
313
|
+
source = "git+https://github.com/matsadler/magnus?branch=main#50cab2380103c39c14765a10bdc4b38a74082285"
|
312
314
|
dependencies = [
|
313
315
|
"proc-macro2",
|
314
316
|
"quote",
|
@@ -443,18 +445,18 @@ dependencies = [
|
|
443
445
|
|
444
446
|
[[package]]
|
445
447
|
name = "rb-sys"
|
446
|
-
version = "0.9.
|
448
|
+
version = "0.9.79"
|
447
449
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
448
|
-
checksum = "
|
450
|
+
checksum = "939fb78db3e4f26665c1d4c7b91ca66d3578335a19aba552d4a6445811d07072"
|
449
451
|
dependencies = [
|
450
452
|
"rb-sys-build",
|
451
453
|
]
|
452
454
|
|
453
455
|
[[package]]
|
454
456
|
name = "rb-sys-build"
|
455
|
-
version = "0.9.
|
457
|
+
version = "0.9.79"
|
456
458
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
457
|
-
checksum = "
|
459
|
+
checksum = "335a95eb0420d52fa94ef12019df3c2c250c6b19cbb3c60bd05cb7e9c362072c"
|
458
460
|
dependencies = [
|
459
461
|
"bindgen",
|
460
462
|
"lazy_static",
|
@@ -418,10 +418,10 @@ impl MmapedFile {
|
|
418
418
|
|
419
419
|
raw_str.as_mut().as_.heap.ptr = self.as_mut_ptr().offset(offset);
|
420
420
|
|
421
|
-
let current_len =
|
421
|
+
let current_len = str.len() as c_long;
|
422
422
|
let new_shared_len = old_cap + current_len;
|
423
423
|
|
424
|
-
|
424
|
+
self.update_rstring_len(raw_str, new_shared_len);
|
425
425
|
continue;
|
426
426
|
}
|
427
427
|
|
@@ -436,7 +436,7 @@ impl MmapedFile {
|
|
436
436
|
//
|
437
437
|
// See https://gitlab.com/gitlab-org/ruby/gems/prometheus-client-mmap/-/issues/45
|
438
438
|
raw_str.as_mut().as_.heap.ptr = self.as_mut_ptr();
|
439
|
-
|
439
|
+
self.update_rstring_len(raw_str, new_len);
|
440
440
|
}
|
441
441
|
}
|
442
442
|
|
@@ -632,6 +632,16 @@ impl MmapedFile {
|
|
632
632
|
unsafe fn rb_string_internal(rb_str: RString) -> NonNull<rb_sys::RString> {
|
633
633
|
mem::transmute::<RString, NonNull<rb_sys::RString>>(rb_str)
|
634
634
|
}
|
635
|
+
|
636
|
+
#[cfg(ruby_lte_3_2)]
|
637
|
+
unsafe fn update_rstring_len(&self, mut raw_str: NonNull<rb_sys::RString>, new_len: c_long) {
|
638
|
+
raw_str.as_mut().as_.heap.len = new_len;
|
639
|
+
}
|
640
|
+
|
641
|
+
#[cfg(ruby_gte_3_3)]
|
642
|
+
unsafe fn update_rstring_len(&self, mut raw_str: NonNull<rb_sys::RString>, new_len: c_long) {
|
643
|
+
raw_str.as_mut().len = new_len;
|
644
|
+
}
|
635
645
|
}
|
636
646
|
|
637
647
|
#[cfg(test)]
|
@@ -772,8 +782,7 @@ mod test {
|
|
772
782
|
if str.as_raw() == child_id {
|
773
783
|
assert_eq!(parent_id, raw_str.as_ref().as_.heap.aux.shared);
|
774
784
|
|
775
|
-
let child_offset =
|
776
|
-
mmap_len as isize - raw_str.as_ref().as_.heap.len as isize;
|
785
|
+
let child_offset = mmap_len as isize - str.len() as isize;
|
777
786
|
assert_eq!(mmap_ptr.offset(child_offset), raw_str.as_ref().as_.heap.ptr);
|
778
787
|
|
779
788
|
child_checked = true;
|
@@ -781,7 +790,7 @@ mod test {
|
|
781
790
|
assert_eq!(parent_id, str.as_raw());
|
782
791
|
|
783
792
|
assert_eq!(mmap_ptr, raw_str.as_ref().as_.heap.ptr);
|
784
|
-
assert_eq!(mmap_len as c_long,
|
793
|
+
assert_eq!(mmap_len as c_long, str.len() as c_long);
|
785
794
|
assert!(raw_str.as_ref().basic.flags & (STR_SHARED | STR_NOEMBED) > 0);
|
786
795
|
assert!(str.is_frozen());
|
787
796
|
|
data/lib/2.7/fast_mmaped_file.so
CHANGED
Binary file
|
Binary file
|
data/lib/3.0/fast_mmaped_file.so
CHANGED
Binary file
|
Binary file
|
data/lib/3.1/fast_mmaped_file.so
CHANGED
Binary file
|
Binary file
|
data/lib/3.2/fast_mmaped_file.so
CHANGED
Binary file
|
Binary file
|
@@ -14,7 +14,7 @@ module Prometheus
|
|
14
14
|
@initial_mmap_file_size = ::Prometheus::Client::PageSize.page_size(fallback_page_size: 4096)
|
15
15
|
@logger = Logger.new($stdout)
|
16
16
|
@pid_provider = Process.method(:pid)
|
17
|
-
@rust_multiprocess_metrics = ENV.fetch('prometheus_rust_multiprocess_metrics',
|
17
|
+
@rust_multiprocess_metrics = ENV.fetch('prometheus_rust_multiprocess_metrics', 'true') == 'true'
|
18
18
|
@multiprocess_files_dir = ENV.fetch('prometheus_multiproc_dir') do
|
19
19
|
Dir.mktmpdir("prometheus-mmap")
|
20
20
|
end
|
@@ -27,7 +27,7 @@ module Prometheus
|
|
27
27
|
Helper::MetricsRepresentation.to_text(metrics)
|
28
28
|
end
|
29
29
|
|
30
|
-
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir, use_rust:
|
30
|
+
def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir, use_rust: true)
|
31
31
|
file_list = Dir.glob(File.join(path, '*.db')).sort
|
32
32
|
.map {|f| Helper::PlainFile.new(f) }
|
33
33
|
.map {|f| [f.filepath, f.multiprocess_mode.to_sym, f.type.to_sym, f.pid] }
|
@@ -14,7 +14,7 @@ module Prometheus
|
|
14
14
|
module Client
|
15
15
|
module Helper
|
16
16
|
# We can't check `Prometheus::Client.configuration` as this creates a circular dependency
|
17
|
-
if (ENV.fetch('prometheus_rust_mmaped_file',
|
17
|
+
if (ENV.fetch('prometheus_rust_mmaped_file', 'true') == "true" &&
|
18
18
|
Prometheus::Client::Helper::Loader.rust_impl_available?)
|
19
19
|
class MmapedFile < FastMmapedFileRs
|
20
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-client-mmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Tobias Schmidt
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-06-
|
14
|
+
date: 2023-06-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rb_sys
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- ext/fast_mmaped_file_rs/Cargo.lock
|
151
151
|
- ext/fast_mmaped_file_rs/Cargo.toml
|
152
152
|
- ext/fast_mmaped_file_rs/README.md
|
153
|
+
- ext/fast_mmaped_file_rs/build.rs
|
153
154
|
- ext/fast_mmaped_file_rs/extconf.rb
|
154
155
|
- ext/fast_mmaped_file_rs/src/error.rs
|
155
156
|
- ext/fast_mmaped_file_rs/src/file_entry.rs
|