prometheus-client-mmap 0.7.0.beta23 → 0.7.0.beta24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af48afe3332fbbead7cf82e59192d3c391737963
4
- data.tar.gz: '0763952a6d406dfabf12dfa661974f5a0418cb8b'
3
+ metadata.gz: fa73b996922691eb05fa808a9b4679a7ce7a65f1
4
+ data.tar.gz: fa415737e695de0191baa29cc9ebc33bf68d6b1c
5
5
  SHA512:
6
- metadata.gz: 216bcbca89792478ccfe281ecc62ac29bb74f0aeb65009861c1817ec9c62a3f434aa0408e6c4bf9ed3f140a30f8beaff4ce535044b1adaf7222ce8bb2ab344a5
7
- data.tar.gz: 63b782b2d7b2aff0810f09a5130f06af756c2e9af17cd8a726519da4210d3ff47e008c3b5bb897a4a5071ab21812ad34efa3340ee777553a6e1e4215d2c2f67a
6
+ metadata.gz: 5cce5f24cf7a5fac8003c32277efe04f4efdf097ff0b3ab6658223c1c261bf79ef8975d0e2675694ec661776494d5184eff77c9491b1d79379a3c588c69940c4
7
+ data.tar.gz: a01c6873e3bb0f9b519997f4d4d8fd1c0aa13c3c5839e84df58cd1d97b6ffbf9a88cf731702fdb92e9feaa40bb8f362a3809744b3ffe01f47b86a491ad75a364
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+ $CFLAGS << ' -Wall -Wextra -Werror'
3
+
4
+ extension_name = 'fast_mmaped_file'
5
+
6
+ dir_config(extension_name)
7
+ create_makefile(extension_name)
Binary file
@@ -1,11 +1,13 @@
1
1
  require 'prometheus/client/helper/entry_parser'
2
2
  require 'prometheus/client/helper/file_locker'
3
3
  require 'mmap'
4
+ require 'fast_mmaped_file'
4
5
 
5
6
  module Prometheus
6
7
  module Client
7
8
  module Helper
8
9
  class MmapedFile < Mmap
10
+ include FastMmapedFile
9
11
  include EntryParser
10
12
  attr_reader :filepath, :size
11
13
 
@@ -41,21 +41,16 @@ module Prometheus
41
41
  end
42
42
 
43
43
  def read_value(key)
44
- @mutex.synchronize do
45
- init_value(key) unless @positions.key?(key)
44
+ init_value(key) unless @positions.key?(key)
46
45
 
47
- pos = @positions[key]
48
- @m[pos..pos + 7].unpack('d')[0]
49
- end
46
+ @m.get_double(@positions[key])
50
47
  end
51
48
 
52
49
  def write_value(key, value)
53
- @mutex.synchronize do
54
- init_value(key) unless @positions.key?(key)
50
+ init_value(key) unless @positions.key?(key)
55
51
 
56
- pos = @positions[key]
57
- @m[pos..pos + 7] = [value].pack('d')
58
- end
52
+ pos = @positions[key]
53
+ @m[pos..pos + 7] = [value].pack('d')
59
54
  end
60
55
 
61
56
  def path
@@ -71,21 +66,24 @@ module Prometheus
71
66
 
72
67
  private
73
68
 
74
- # Initialize a value. Lock must be held by caller.
75
69
  def init_value(key)
76
- until @m.try_add_entry(key, 0.0) do
77
- filepath = @m.filepath
78
- size = @m.size
79
- @m.close
70
+ @mutex.synchronize do
71
+ return if @positions.key?(key)
80
72
 
81
- File.truncate(filepath, size * 2)
82
- @m = Helper::MmapedFile.open(filepath)
83
- end
73
+ until @m.try_add_entry(key, 0.0) do
74
+ filepath = @m.filepath
75
+ size = @m.size
76
+ @m.close
84
77
 
85
- # Update how much space we've used.
86
- @used = @m.used
78
+ File.truncate(filepath, size * 2)
79
+ @m = Helper::MmapedFile.open(filepath)
80
+ end
87
81
 
88
- @positions[key] = @used - 8
82
+ # Update how much space we've used.
83
+ @used = @m.used
84
+
85
+ @positions[key] = @used - 8
86
+ end
89
87
  end
90
88
 
91
89
  # Yield (key, pos). No locking is performed.
@@ -1,5 +1,5 @@
1
1
  module Prometheus
2
2
  module Client
3
- VERSION = '0.7.0.beta23'.freeze
3
+ VERSION = '0.7.0.beta24'.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.7.0.beta23
4
+ version: 0.7.0.beta24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmidt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-15 00:00:00.000000000 Z
12
+ date: 2017-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mmap2
@@ -45,15 +45,32 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.1.1
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake-compiler
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.4
48
62
  description:
49
63
  email:
50
64
  - ts@soundcloud.com
51
65
  - pawel@gitlab.com
52
66
  executables: []
53
- extensions: []
67
+ extensions:
68
+ - ext/fast_mmaped_file/extconf.rb
54
69
  extra_rdoc_files: []
55
70
  files:
56
71
  - README.md
72
+ - ext/fast_mmaped_file/extconf.rb
73
+ - lib/fast_mmaped_file.bundle
57
74
  - lib/prometheus.rb
58
75
  - lib/prometheus/client.rb
59
76
  - lib/prometheus/client/configuration.rb