prometheus-client-mmap 0.28.1-x86_64-darwin → 1.0.1-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.tool-versions +1 -1
  3. data/README.md +2 -30
  4. data/ext/fast_mmaped_file_rs/extconf.rb +1 -3
  5. data/ext/fast_mmaped_file_rs/src/error.rs +8 -0
  6. data/ext/fast_mmaped_file_rs/src/file_info.rs +51 -1
  7. data/ext/fast_mmaped_file_rs/src/mmap/inner.rs +38 -13
  8. data/ext/fast_mmaped_file_rs/src/mmap.rs +71 -5
  9. data/lib/2.7/fast_mmaped_file_rs.bundle +0 -0
  10. data/lib/3.0/fast_mmaped_file_rs.bundle +0 -0
  11. data/lib/3.1/fast_mmaped_file_rs.bundle +0 -0
  12. data/lib/3.2/fast_mmaped_file_rs.bundle +0 -0
  13. data/lib/prometheus/client/configuration.rb +1 -2
  14. data/lib/prometheus/client/formats/text.rb +1 -12
  15. data/lib/prometheus/client/helper/mmaped_file.rb +3 -14
  16. data/lib/prometheus/client/rack/exporter.rb +1 -3
  17. data/lib/prometheus/client/version.rb +1 -1
  18. metadata +4 -46
  19. data/ext/fast_mmaped_file/extconf.rb +0 -30
  20. data/ext/fast_mmaped_file/fast_mmaped_file.c +0 -122
  21. data/ext/fast_mmaped_file/file_format.c +0 -5
  22. data/ext/fast_mmaped_file/file_format.h +0 -11
  23. data/ext/fast_mmaped_file/file_parsing.c +0 -195
  24. data/ext/fast_mmaped_file/file_parsing.h +0 -27
  25. data/ext/fast_mmaped_file/file_reading.c +0 -102
  26. data/ext/fast_mmaped_file/file_reading.h +0 -30
  27. data/ext/fast_mmaped_file/globals.h +0 -14
  28. data/ext/fast_mmaped_file/mmap.c +0 -428
  29. data/ext/fast_mmaped_file/mmap.h +0 -61
  30. data/ext/fast_mmaped_file/rendering.c +0 -199
  31. data/ext/fast_mmaped_file/rendering.h +0 -8
  32. data/ext/fast_mmaped_file/utils.c +0 -56
  33. data/ext/fast_mmaped_file/utils.h +0 -22
  34. data/ext/fast_mmaped_file/value_access.c +0 -242
  35. data/ext/fast_mmaped_file/value_access.h +0 -15
  36. data/lib/2.7/fast_mmaped_file.bundle +0 -0
  37. data/lib/3.0/fast_mmaped_file.bundle +0 -0
  38. data/lib/3.1/fast_mmaped_file.bundle +0 -0
  39. data/lib/3.2/fast_mmaped_file.bundle +0 -0
  40. data/lib/prometheus/client/helper/loader.rb +0 -44
  41. data/vendor/c/hashmap/.gitignore +0 -52
  42. data/vendor/c/hashmap/LICENSE +0 -21
  43. data/vendor/c/hashmap/README.md +0 -90
  44. data/vendor/c/hashmap/_config.yml +0 -1
  45. data/vendor/c/hashmap/src/hashmap.c +0 -692
  46. data/vendor/c/hashmap/src/hashmap.h +0 -267
  47. data/vendor/c/hashmap/test/Makefile +0 -22
  48. data/vendor/c/hashmap/test/hashmap_test.c +0 -608
  49. data/vendor/c/jsmn/.travis.yml +0 -4
  50. data/vendor/c/jsmn/LICENSE +0 -20
  51. data/vendor/c/jsmn/Makefile +0 -41
  52. data/vendor/c/jsmn/README.md +0 -168
  53. data/vendor/c/jsmn/example/jsondump.c +0 -126
  54. data/vendor/c/jsmn/example/simple.c +0 -76
  55. data/vendor/c/jsmn/jsmn.c +0 -314
  56. data/vendor/c/jsmn/jsmn.h +0 -76
  57. data/vendor/c/jsmn/library.json +0 -16
  58. data/vendor/c/jsmn/test/test.h +0 -27
  59. data/vendor/c/jsmn/test/tests.c +0 -407
  60. data/vendor/c/jsmn/test/testutil.h +0 -94
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89d04a2d72d09caa22e308eb773c46fc0b68e63d12fae738f0972776967967cd
4
- data.tar.gz: 9e7855cef20f44b8c9447bd166e43e9835d824a7278e90f1d102a0d9b29312fb
3
+ metadata.gz: be3b67bb7ddbb4629ec612dc55a2f9342d8a41c9290cc6da64edf8d816c0c5f5
4
+ data.tar.gz: cb98fa2e2758f5acffb31c0379c406dc6d7d40de200101dc63cc4dbc6a4d3d86
5
5
  SHA512:
6
- metadata.gz: 53fd89172270e5c6540e7d14fb7faee2650b50c89e20f47cc9f51f45987202dccfb6a361267dfe555e66118830750e30b774005a069e30a6a8630b34029f31d7
7
- data.tar.gz: 0e2027b2855e698e8e8aa57076c8d04becbe9e0e56e77ea36c372cf90aa21ffe1904bfd1bea7222d6e07342d74056fedfe3951edc71c28b72ad9289c72ab0559
6
+ metadata.gz: b568bda8be9e2ca19e9d6a645953ab7eff7b11477b5008615a263e0d43dc2ba567e899554c10fdc65a31f257c1dedf92cadf4a51be3500b770e57facf168396c
7
+ data.tar.gz: 965217cb2aa20f781f513b8135636e153b33d97c848064649e24ba4178f0b9c1ab1bbd123a54d05d268cb5e8bd3caf4ee138f75ec6f08535178b4125ce7d2947
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- rust 1.65.0
1
+ rust 1.73.0
data/README.md CHANGED
@@ -53,19 +53,9 @@ http_requests.increment
53
53
 
54
54
  ## Rust extension
55
55
 
56
- In an effort to improve maintainability, there is now a Rust
56
+ This gem now uses a rewritten Rust extension instead of C.
57
57
  implementation that reads the metric files and outputs the multiprocess
58
- metrics to text. If `rustc` is available, then the Rust extension will
59
- be built automatically. The `use_rust` keyword argument can be used:
60
-
61
- ```ruby
62
- puts Prometheus::Client::Formats::Text.marshal_multiprocess(use_rust: true)
63
- ```
64
-
65
- Starting with v0.26.0, `use_rust` defaults to `true`.
66
-
67
- Note that this parameter will likely be deprecated and removed once the Rust
68
- extension becomes the only supported mode.
58
+ metrics to text. This implementation is significantly faster than the C extension.
69
59
 
70
60
  ### Rack middleware
71
61
 
@@ -219,24 +209,6 @@ Set `prometheus_multiproc_dir` environment variable to the path where you want m
219
209
  prometheus_multiproc_dir=/tmp
220
210
  ```
221
211
 
222
- ### Multiprocess metrics via Rust extension
223
-
224
- By default, the Rust extension will be used to read and write multiprocess
225
- metrics if the `fast_mmaped_file_rs` extension is available. This should
226
- be significantly faster than the C extension.
227
-
228
- If the environment variable `prometheus_rust_multiprocess_metrics=false`
229
- is set or if the `rust_multiprocess_metrics` configuration setting is
230
- `false` , the C extension will be used.
231
-
232
- ### Read and write metrics via Rust extension
233
-
234
- By default, the Rust extension will be used to read and write metrics
235
- from the mmaped file if the `fast_mmaped_file_rs` extension is available.
236
-
237
- To use the C extension, set the environment variable
238
- `prometheus_rust_mmaped_file=false`.
239
-
240
212
  ## Pitfalls
241
213
 
242
214
  ### PID cardinality
@@ -24,7 +24,5 @@ if find_executable('rustc')
24
24
  ARGV = trimmed_argv
25
25
  end
26
26
  else
27
- puts 'rustc not found, skipping Rust extension.'
28
-
29
- File.write('Makefile', dummy_makefile($srcdir).join(''))
27
+ raise 'rustc not found. prometheus-client-mmap now requires Rust.'
30
28
  end
@@ -100,6 +100,13 @@ pub enum MmapError {
100
100
  /// No mmap open.
101
101
  #[error("unmapped file")]
102
102
  UnmappedFile,
103
+ /// File length changed by another process.
104
+ #[error("size of {path} {len} does not match previous size {expected_len}. Another process may have modified it.")]
105
+ UnexpectedFileLength {
106
+ path: String,
107
+ len: usize,
108
+ expected_len: usize,
109
+ },
103
110
  /// A custom error message with `strerror(3)` appended.
104
111
  #[error("{0}")]
105
112
  WithErrno(String),
@@ -162,6 +169,7 @@ impl MmapError {
162
169
  MmapError::Other(_) => RubyError::Arg,
163
170
  MmapError::PromParsing(_) => RubyError::PromParsing,
164
171
  MmapError::UnmappedFile => RubyError::Io,
172
+ MmapError::UnexpectedFileLength { .. } => RubyError::Runtime,
165
173
  MmapError::WithErrno(_) => RubyError::Io,
166
174
  }
167
175
  }
@@ -91,6 +91,11 @@ impl FileInfo {
91
91
 
92
92
  match self.file.read_to_end(buf) {
93
93
  Ok(n) if n == self.len => Ok(()),
94
+ // A worker may expand the file between our `stat` and `read`, no harm done.
95
+ Ok(n) if n > self.len => {
96
+ self.len = n;
97
+ Ok(())
98
+ }
94
99
  Ok(_) => Err(MmapError::io(
95
100
  "read",
96
101
  &self.path,
@@ -106,6 +111,8 @@ mod test {
106
111
  use magnus::{eval, RArray, Symbol};
107
112
  use rand::{thread_rng, Rng};
108
113
  use sha2::{Digest, Sha256};
114
+ use std::fs;
115
+ use std::io::Write;
109
116
 
110
117
  use super::*;
111
118
  use crate::testhelper::TestFile;
@@ -165,7 +172,7 @@ mod test {
165
172
 
166
173
  let mut info = FileInfo {
167
174
  file,
168
- path,
175
+ path: path.clone(),
169
176
  len: buf.len(),
170
177
  multiprocess_mode: Symbol::new("puma"),
171
178
  type_: Symbol::new("max"),
@@ -187,4 +194,47 @@ mod test {
187
194
 
188
195
  assert_eq!(in_hash, out_hash, "content hashes");
189
196
  }
197
+
198
+ #[test]
199
+ fn test_read_from_file_resized() {
200
+ let _cleanup = unsafe { magnus::embed::init() };
201
+ let ruby = magnus::Ruby::get().unwrap();
202
+ crate::init(&ruby).unwrap();
203
+
204
+ const BUF_LEN: usize = 1 << 14; // 16KiB
205
+
206
+ // Create a buffer with random data.
207
+ let mut buf = vec![0u8; BUF_LEN];
208
+ thread_rng().fill(buf.as_mut_slice());
209
+
210
+ let TestFile {
211
+ file,
212
+ path,
213
+ dir: _dir,
214
+ } = TestFile::new(&buf);
215
+
216
+ let mut info = FileInfo {
217
+ file,
218
+ path: path.clone(),
219
+ len: buf.len(),
220
+ multiprocess_mode: Symbol::new("puma"),
221
+ type_: Symbol::new("max"),
222
+ pid: "worker-0_0".to_string(),
223
+ };
224
+
225
+ let mut resized_file = fs::OpenOptions::new()
226
+ .write(true)
227
+ .append(true)
228
+ .open(path)
229
+ .unwrap();
230
+
231
+ // Write data to file after it has been `stat`ed in the
232
+ // constructor.
233
+ resized_file.write_all(&[1; 1024]).unwrap();
234
+
235
+ let mut out_buf = Vec::new();
236
+ info.read_from_file(&mut out_buf).unwrap();
237
+
238
+ assert_eq!(BUF_LEN + 1024, info.len, "resized file updated len");
239
+ }
190
240
  }
@@ -5,7 +5,7 @@ use std::fs::File;
5
5
  use std::mem::size_of;
6
6
  use std::ops::Range;
7
7
  use std::os::unix::prelude::{AsRawFd, RawFd};
8
- use std::path::PathBuf;
8
+ use std::path::{Path, PathBuf};
9
9
 
10
10
  use crate::error::{MmapError, RubyError};
11
11
  use crate::raw_entry::RawEntry;
@@ -34,6 +34,8 @@ pub(super) struct InnerMmap {
34
34
  ///
35
35
  /// Equivalent to `i_mm->t->real` in the C implementation.
36
36
  len: usize,
37
+ /// The length of the file being mmapped at the time of mapping.
38
+ file_len: usize,
37
39
  }
38
40
 
39
41
  impl InnerMmap {
@@ -41,19 +43,12 @@ impl InnerMmap {
41
43
  /// Use when mmapping a file for the first time. When re-mapping a file
42
44
  /// after expanding it the `reestablish` function should be used.
43
45
  pub fn new(path: PathBuf, file: File) -> Result<Self> {
44
- let stat = file.metadata().map_err(|e| {
45
- MmapError::legacy(
46
- format!("Can't stat {}: {e}", path.display()),
47
- RubyError::Arg,
48
- )
49
- })?;
50
-
51
- let file_size = util::cast_chk::<_, usize>(stat.len(), "file length")?;
46
+ let initial_file_len = get_file_len(&path, &file)?;
52
47
 
53
48
  // We need to ensure the underlying file descriptor is at least a page size.
54
49
  // Otherwise, we could get a SIGBUS error if mmap() attempts to read or write
55
50
  // past the file.
56
- let reserve_size = Self::next_page_boundary(file_size)?;
51
+ let reserve_size = Self::next_page_boundary(initial_file_len)?;
57
52
 
58
53
  // Cast: no-op.
59
54
  Self::reserve_mmap_file_bytes(file.as_raw_fd(), reserve_size as off_t).map_err(|e| {
@@ -67,21 +62,23 @@ impl InnerMmap {
67
62
  })?;
68
63
 
69
64
  // Ensure we always have space for the header.
70
- let map_len = file_size.max(HEADER_SIZE);
65
+ let map_len = initial_file_len.max(HEADER_SIZE);
71
66
 
72
67
  // SAFETY: There is the possibility of UB if the file is modified outside of
73
68
  // this program.
74
69
  let map = unsafe { MmapOptions::new().len(map_len).map_mut(&file) }.map_err(|e| {
75
70
  MmapError::legacy(format!("mmap failed ({}): {e}", errno()), RubyError::Arg)
76
71
  })?;
72
+ let file_len = util::cast_chk::<_, usize>(reserve_size, "file length")?;
77
73
 
78
- let len = file_size;
74
+ let len = initial_file_len;
79
75
 
80
76
  Ok(Self {
81
77
  file,
82
78
  path,
83
79
  map,
84
80
  len,
81
+ file_len,
85
82
  })
86
83
  }
87
84
 
@@ -97,12 +94,14 @@ impl InnerMmap {
97
94
  // to the old length at this point if closing the file. Matching C implementation
98
95
  // for now.
99
96
  let len = map_len;
97
+ let file_len = get_file_len(&path, &file)?;
100
98
 
101
99
  Ok(Self {
102
100
  file,
103
101
  path,
104
102
  map,
105
103
  len,
104
+ file_len,
106
105
  })
107
106
  }
108
107
 
@@ -186,7 +185,7 @@ impl InnerMmap {
186
185
  self.len
187
186
  }
188
187
 
189
- /// The total length in bytes of the mmapped file.
188
+ /// The total length in bytes of the mmapped region of the file.
190
189
  ///
191
190
  /// Equivalent to `i_mm->t->len` in the C implementation.
192
191
  #[inline]
@@ -194,6 +193,21 @@ impl InnerMmap {
194
193
  self.map.len()
195
194
  }
196
195
 
196
+ /// `stat` the mmapped file and return its length.
197
+ pub fn check_file_len(&self) -> Result<usize> {
198
+ get_file_len(&self.path, &self.file)
199
+ }
200
+
201
+ /// The length of the file at the time it was mmapped.
202
+ pub fn file_len(&self) -> usize {
203
+ self.file_len
204
+ }
205
+
206
+ /// The path of the mmapped file.
207
+ pub fn path(&self) -> String {
208
+ self.path.to_string_lossy().to_string()
209
+ }
210
+
197
211
  /// Update the length of the mmap considered to be written.
198
212
  pub fn set_len(&mut self, len: usize) {
199
213
  self.len = len;
@@ -312,6 +326,17 @@ impl InnerMmap {
312
326
  }
313
327
  }
314
328
 
329
+ fn get_file_len(path: &Path, file: &File) -> Result<usize> {
330
+ let stat = file.metadata().map_err(|e| {
331
+ MmapError::legacy(
332
+ format!("Can't stat {}: {e}", path.display()),
333
+ RubyError::Arg,
334
+ )
335
+ })?;
336
+
337
+ util::cast_chk::<_, usize>(stat.len(), "file length")
338
+ }
339
+
315
340
  #[cfg(test)]
316
341
  mod test {
317
342
  use nix::unistd::{self, SysconfVar};
@@ -441,17 +441,49 @@ impl MmapedFile {
441
441
  }
442
442
 
443
443
  /// Check that the mmap is large enough to contain the value to be added,
444
- /// and expand it to fit if necessary.
444
+ /// and expand it to fit if necessary. Will return an error if the file
445
+ /// has been resized by another process.
445
446
  fn check_expand(&self, rb_self: Obj<Self>, key_len: usize) -> magnus::error::Result<()> {
446
447
  // CAST: no-op on 32-bit, widening on 64-bit.
447
448
  let used = self.inner(|inner| inner.load_used())? as usize;
448
449
  let entry_len = RawEntry::calc_total_len(key_len)?;
450
+ let required_len = used.add_chk(entry_len)?;
451
+ let mut target_cap = self.capacity();
449
452
 
453
+ let mut needs_resize = false;
450
454
  // We need the mmapped region to contain at least one byte beyond the
451
- // written data to create a NUL- terminated C string. Validate that
452
- // new length does not exactly match or exceed the length of the mmap.
453
- while self.capacity() <= used.add_chk(entry_len)? {
454
- self.expand_to_fit(rb_self, self.capacity().mul_chk(2)?)?;
455
+ // written data to create a NUL-terminated C string. Validate that
456
+ // new length does not exactly match the length of the mmap.
457
+ if target_cap <= required_len {
458
+ needs_resize = true;
459
+ target_cap = required_len + 1;
460
+ }
461
+
462
+ let (current_file_len, original_file_len) =
463
+ self.inner(|inner| Ok((inner.check_file_len()?, inner.file_len())))?;
464
+
465
+ let file_modified = current_file_len != original_file_len;
466
+ if file_modified {
467
+ // Ensure our new capacity is at least as large as the actual file.
468
+ // Erroring out without first resizing the mmap would leave us stuck
469
+ // in a bad state.
470
+ target_cap = current_file_len
471
+ }
472
+
473
+ if needs_resize {
474
+ self.expand_to_fit(rb_self, target_cap)?;
475
+ }
476
+
477
+ if file_modified {
478
+ // Return an error so the caller is alerted that there were concurrent writes to the
479
+ // file.
480
+ let path = self.inner(|inner| Ok(inner.path()))?;
481
+ return Err(MmapError::UnexpectedFileLength {
482
+ path,
483
+ len: current_file_len,
484
+ expected_len: original_file_len,
485
+ }
486
+ .into());
455
487
  }
456
488
 
457
489
  Ok(())
@@ -652,6 +684,7 @@ mod test {
652
684
  use super::*;
653
685
  use crate::raw_entry::RawEntry;
654
686
  use crate::testhelper::TestFile;
687
+ use std::os::unix::prelude::AsRawFd;
655
688
 
656
689
  /// Create a wrapped MmapedFile object.
657
690
  fn create_obj() -> Obj<MmapedFile> {
@@ -881,4 +914,37 @@ mod test {
881
914
  // Validate that we have expanded the mmap, ensuring a trailing NUL.
882
915
  assert!(rs_self.capacity() > current_cap);
883
916
  }
917
+
918
+ #[test]
919
+ fn test_detect_external_resize() {
920
+ let _cleanup = unsafe { magnus::embed::init() };
921
+ let ruby = magnus::Ruby::get().unwrap();
922
+ crate::init(&ruby).unwrap();
923
+
924
+ let TestFile {
925
+ file,
926
+ path,
927
+ dir: _dir,
928
+ } = TestFile::new(&[0u8; 8]);
929
+
930
+ let path_str = path.display().to_string();
931
+ let rpath = RString::new(&path_str);
932
+
933
+ // Object created successfully
934
+ let result: std::result::Result<Obj<MmapedFile>, Error> =
935
+ eval!("FastMmapedFileRs.new(path)", path = rpath);
936
+ assert!(result.is_ok());
937
+ let obj = result.unwrap();
938
+
939
+ let rs_self = &*obj;
940
+
941
+ let file_len = 1 << 32;
942
+ nix::unistd::ftruncate(file.as_raw_fd(), file_len).unwrap();
943
+
944
+ // We error when the file is externally modified.
945
+ assert!(rs_self.check_expand(obj, 512).is_err());
946
+
947
+ // We updated the object to use the new size.
948
+ assert_eq!(rs_self.capacity(), file_len as usize);
949
+ }
884
950
  }
Binary file
Binary file
Binary file
Binary file
@@ -7,14 +7,13 @@ require 'tmpdir'
7
7
  module Prometheus
8
8
  module Client
9
9
  class Configuration
10
- attr_accessor :value_class, :multiprocess_files_dir, :initial_mmap_file_size, :logger, :pid_provider, :rust_multiprocess_metrics
10
+ attr_accessor :value_class, :multiprocess_files_dir, :initial_mmap_file_size, :logger, :pid_provider
11
11
 
12
12
  def initialize
13
13
  @value_class = ::Prometheus::Client::MmapedValue
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', 'true') == 'true'
18
17
  @multiprocess_files_dir = ENV.fetch('prometheus_multiproc_dir') do
19
18
  Dir.mktmpdir("prometheus-mmap")
20
19
  end
@@ -1,6 +1,5 @@
1
1
  require 'prometheus/client/uses_value_type'
2
2
  require 'prometheus/client/helper/json_parser'
3
- require 'prometheus/client/helper/loader'
4
3
  require 'prometheus/client/helper/plain_file'
5
4
  require 'prometheus/client/helper/metrics_processing'
6
5
  require 'prometheus/client/helper/metrics_representation'
@@ -27,22 +26,12 @@ module Prometheus
27
26
  Helper::MetricsRepresentation.to_text(metrics)
28
27
  end
29
28
 
30
- def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir, use_rust: true)
29
+ def marshal_multiprocess(path = Prometheus::Client.configuration.multiprocess_files_dir)
31
30
  file_list = Dir.glob(File.join(path, '*.db')).sort
32
31
  .map {|f| Helper::PlainFile.new(f) }
33
32
  .map {|f| [f.filepath, f.multiprocess_mode.to_sym, f.type.to_sym, f.pid] }
34
33
 
35
- if use_rust && Prometheus::Client::Helper::Loader.rust_impl_available?
36
34
  FastMmapedFileRs.to_metrics(file_list.to_a)
37
- else
38
- FastMmapedFile.to_metrics(file_list.to_a)
39
- end
40
- end
41
-
42
- def rust_impl_available?
43
- return @rust_available unless @rust_available.nil?
44
-
45
- check_for_rust
46
35
  end
47
36
 
48
37
  private
@@ -1,29 +1,18 @@
1
1
  require 'prometheus/client/helper/entry_parser'
2
2
  require 'prometheus/client/helper/file_locker'
3
- require 'prometheus/client/helper/loader'
4
3
 
5
4
  # load precompiled extension if available
6
5
  begin
7
6
  ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
8
- require_relative "../../../#{ruby_version}/fast_mmaped_file"
7
+ require_relative "../../../#{ruby_version}/fast_mmaped_file_rs"
9
8
  rescue LoadError
10
- require 'fast_mmaped_file'
9
+ require 'fast_mmaped_file_rs'
11
10
  end
12
11
 
13
12
  module Prometheus
14
13
  module Client
15
14
  module Helper
16
- # We can't check `Prometheus::Client.configuration` as this creates a circular dependency
17
- if (ENV.fetch('prometheus_rust_mmaped_file', 'true') == "true" &&
18
- Prometheus::Client::Helper::Loader.rust_impl_available?)
19
- class MmapedFile < FastMmapedFileRs
20
- end
21
- else
22
- class MmapedFile < FastMmapedFile
23
- end
24
- end
25
-
26
- class MmapedFile
15
+ class MmapedFile < FastMmapedFileRs
27
16
  include EntryParser
28
17
 
29
18
  attr_reader :filepath, :size
@@ -62,10 +62,8 @@ module Prometheus
62
62
  end
63
63
 
64
64
  def respond_with(format)
65
- rust_enabled = Prometheus::Client.configuration.rust_multiprocess_metrics
66
-
67
65
  response = if Prometheus::Client.configuration.value_class.multiprocess
68
- format.marshal_multiprocess(use_rust: rust_enabled)
66
+ format.marshal_multiprocess
69
67
  else
70
68
  format.marshal
71
69
  end
@@ -1,5 +1,5 @@
1
1
  module Prometheus
2
2
  module Client
3
- VERSION = '0.28.1'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  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.28.1
4
+ version: 1.0.1
5
5
  platform: x86_64-darwin
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-10-05 00:00:00.000000000 Z
14
+ date: 2023-12-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rb_sys
@@ -129,23 +129,6 @@ extra_rdoc_files: []
129
129
  files:
130
130
  - ".tool-versions"
131
131
  - README.md
132
- - ext/fast_mmaped_file/extconf.rb
133
- - ext/fast_mmaped_file/fast_mmaped_file.c
134
- - ext/fast_mmaped_file/file_format.c
135
- - ext/fast_mmaped_file/file_format.h
136
- - ext/fast_mmaped_file/file_parsing.c
137
- - ext/fast_mmaped_file/file_parsing.h
138
- - ext/fast_mmaped_file/file_reading.c
139
- - ext/fast_mmaped_file/file_reading.h
140
- - ext/fast_mmaped_file/globals.h
141
- - ext/fast_mmaped_file/mmap.c
142
- - ext/fast_mmaped_file/mmap.h
143
- - ext/fast_mmaped_file/rendering.c
144
- - ext/fast_mmaped_file/rendering.h
145
- - ext/fast_mmaped_file/utils.c
146
- - ext/fast_mmaped_file/utils.h
147
- - ext/fast_mmaped_file/value_access.c
148
- - ext/fast_mmaped_file/value_access.h
149
132
  - ext/fast_mmaped_file_rs/.cargo/config.toml
150
133
  - ext/fast_mmaped_file_rs/Cargo.lock
151
134
  - ext/fast_mmaped_file_rs/Cargo.toml
@@ -163,13 +146,9 @@ files:
163
146
  - ext/fast_mmaped_file_rs/src/raw_entry.rs
164
147
  - ext/fast_mmaped_file_rs/src/testhelper.rs
165
148
  - ext/fast_mmaped_file_rs/src/util.rs
166
- - lib/2.7/fast_mmaped_file.bundle
167
149
  - lib/2.7/fast_mmaped_file_rs.bundle
168
- - lib/3.0/fast_mmaped_file.bundle
169
150
  - lib/3.0/fast_mmaped_file_rs.bundle
170
- - lib/3.1/fast_mmaped_file.bundle
171
151
  - lib/3.1/fast_mmaped_file_rs.bundle
172
- - lib/3.2/fast_mmaped_file.bundle
173
152
  - lib/3.2/fast_mmaped_file_rs.bundle
174
153
  - lib/prometheus.rb
175
154
  - lib/prometheus/client.rb
@@ -180,7 +159,6 @@ files:
180
159
  - lib/prometheus/client/helper/entry_parser.rb
181
160
  - lib/prometheus/client/helper/file_locker.rb
182
161
  - lib/prometheus/client/helper/json_parser.rb
183
- - lib/prometheus/client/helper/loader.rb
184
162
  - lib/prometheus/client/helper/metrics_processing.rb
185
163
  - lib/prometheus/client/helper/metrics_representation.rb
186
164
  - lib/prometheus/client/helper/mmaped_file.rb
@@ -201,26 +179,6 @@ files:
201
179
  - lib/prometheus/client/support/unicorn.rb
202
180
  - lib/prometheus/client/uses_value_type.rb
203
181
  - lib/prometheus/client/version.rb
204
- - vendor/c/hashmap/.gitignore
205
- - vendor/c/hashmap/LICENSE
206
- - vendor/c/hashmap/README.md
207
- - vendor/c/hashmap/_config.yml
208
- - vendor/c/hashmap/src/hashmap.c
209
- - vendor/c/hashmap/src/hashmap.h
210
- - vendor/c/hashmap/test/Makefile
211
- - vendor/c/hashmap/test/hashmap_test.c
212
- - vendor/c/jsmn/.travis.yml
213
- - vendor/c/jsmn/LICENSE
214
- - vendor/c/jsmn/Makefile
215
- - vendor/c/jsmn/README.md
216
- - vendor/c/jsmn/example/jsondump.c
217
- - vendor/c/jsmn/example/simple.c
218
- - vendor/c/jsmn/jsmn.c
219
- - vendor/c/jsmn/jsmn.h
220
- - vendor/c/jsmn/library.json
221
- - vendor/c/jsmn/test/test.h
222
- - vendor/c/jsmn/test/tests.c
223
- - vendor/c/jsmn/test/testutil.h
224
182
  homepage: https://gitlab.com/gitlab-org/prometheus-client-mmap
225
183
  licenses:
226
184
  - Apache-2.0
@@ -246,6 +204,6 @@ requirements: []
246
204
  rubygems_version: 3.4.4
247
205
  signing_key:
248
206
  specification_version: 4
249
- summary: A suite of instrumentation metric primitivesthat can be exposed through a
250
- web services interface.
207
+ summary: A suite of instrumentation metric primitives that can be exposed through
208
+ a web services interface.
251
209
  test_files: []
@@ -1,30 +0,0 @@
1
- require 'mkmf'
2
- require 'fileutils'
3
-
4
- $CFLAGS << ' -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra'
5
-
6
- if enable_config('fail-on-warning')
7
- $CFLAGS << ' -Werror'
8
- end
9
-
10
- if enable_config('debug')
11
- $CFLAGS << ' -O0 -g'
12
- end
13
-
14
- if enable_config('address-sanitizer')
15
- $CFLAGS << ' -O -fsanitize=address -fno-omit-frame-pointer -g'
16
- end
17
-
18
- CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
19
-
20
- cwd = File.expand_path(File.dirname(__FILE__))
21
- vendor_dir = File.join(cwd, '../../vendor/c')
22
- src_dir = File.join(cwd, '../../ext/fast_mmaped_file')
23
-
24
- src_files = %W[#{vendor_dir}/jsmn/jsmn.c #{vendor_dir}/hashmap/src/hashmap.c]
25
- FileUtils.cp(src_files, src_dir)
26
-
27
- $INCFLAGS << " -I#{vendor_dir}/jsmn -I#{vendor_dir}/hashmap/src"
28
-
29
- dir_config('fast_mmaped_file')
30
- create_makefile('fast_mmaped_file')